# -*- coding: UTF8 -*-
# 目前整理的项目内容：地基、主体结构

import os
import random
import re
import time
import pandas as pd
import openpyxl
from PIL import Image
from check_project import CHECK_PROJECTS
from datetime import timedelta
import urls
from urls import TEMPLATES
from openpyxl.drawing.image import Image
from openpyxl.drawing.spreadsheet_drawing import AnchorMarker, OneCellAnchor
from openpyxl.drawing.xdr import XDRPositiveSize2D
from openpyxl.styles import Font, Alignment
from openpyxl.utils.units import pixels_to_EMU
from pathlib import Path
import copy
from urls import ThirdBasePath


# 根据字数调整字体大小
def font_size(text):
    if len(text) <= 10:
        return 10
    elif len(text) <= 15:
        return 9
    elif len(text) <= 20:
        return 8
    elif len(text) <= 25:
        return 6
    elif len(text) <= 30:
        return 5


def str_date(DATE):
    data = pd.Timestamp(DATE, tz=None).to_pydatetime()

    return str(data.year) + "年" + str(data.month) + \
        '月' + str(data.day) + '日'


def JudgeBool(project):
    if project == '是' or project == '√':
        return True
    else:
        return False


def RELEX_DATE(DIR_DTAT, nday):
    if nday >= 0:
        data = pd.to_datetime(DIR_DTAT) + timedelta(nday)
    else:
        nday = abs(nday)
        data = pd.to_datetime(DIR_DTAT) - timedelta(nday)

    return data


def __write__(DIR_SHEET, row, col, value, font_size=9):  # 单纯写入某个单元格

    DIR_SHEET.cell(row=row, column=col, value=value).alignment = Alignment(
        horizontal='center', vertical='center', wrap_text=True)
    DIR_SHEET.cell(row=row, column=col).font = Font(size=font_size)


def __inquire__image__(sheet, imagepath=None, imagesheape=None,
                       row=None, col=None, rowOff=0, colOff=60000):
    """把图片插入到excel文件中的指定位置
    插入到指定单元格然后向右偏移一点距离，目的是不让图片的边框和单元格的边框重合
    :param sheet:工作表名称
    :param row：起始单元格行号
    :param col:起始单元格列号
    :param rowOff：行偏移距离（10000为单位）
    :param colOff：列偏移距离（10000为单位）
    :return:
    """
    if imagepath is None:
        imagepath = r'C:\Users\lx\Documents\myapp\static\11.png'
    if imagesheape is None:
        imagesheape = [25, 25]
    if rowOff is None:
        rowOff = 0
    if colOff is None:
        colOff = 60000

    img = Image(imagepath)
    # 设置图片的宽和高
    img.width, img.height = imagesheape

    def offset_img(img, row, col, rowOff, colOff):
        """精确设置图片位置，偏移量以万为单位进行微调吧，具体计算公式太麻烦了
        row column 的索引都是从0开始的,我这里要把图片插入到单元格B10
        """
        p2e = pixels_to_EMU
        h, w = img.height, img.width
        size = XDRPositiveSize2D(p2e(w), p2e(h))
        marker = AnchorMarker(
            col=col - 1,
            colOff=colOff,
            row=row - 1,
            rowOff=rowOff)
        img.anchor = OneCellAnchor(_from=marker, ext=size)

        offset_img(img, row, col, rowOff, colOff)
        # 将图片添加到excel中
        sheet.add_image(img)


# 封面


def cover(project_information:dict[str], new_path__: str):
    """
    :param project_information: 信息表
    :param new_path__: 新的文件名
    :return:

    """
    dir_path = TEMPLATES['封面']['报审表']
    DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

    DIR_SHEET = DirWorkBooK[DirWorkBooK.sheetnames[0]]
    try:
        DIR_SHEET['Q5'] = project_information['检验批编号']

    except BaseException:
        DIR_SHEET['Q5'] = ''
    DIR_SHEET['E5'] = project_information['项目名称']
    DIR_SHEET['G3'] = project_information['分项工程'] + '检验批'
    DIR_SHEET['C8'] = project_information['监理单位']
    DIR_SHEET['F10'] = project_information['检验批部位'] + \
        project_information['分项工程']

    try:
        DIR_SHEET['P22'] = str_date(RELEX_DATE(project_information['时间'], -1))
    except BaseException:
        pass

    bool_pool = ['☑', '□']

    DIR_SHEET['E13'] = bool_pool[1]
    DIR_SHEET['E13'].font = Font(color='000000')
    DIR_SHEET['E14'] = bool_pool[1]
    DIR_SHEET['E14'].font = Font(color='000000')
    DIR_SHEET['E15'] = bool_pool[0]
    DIR_SHEET['E15'].font = Font(color='000000')
    DIR_SHEET['E16'] = bool_pool[0]
    DIR_SHEET['E16'].font = Font(color='000000')
    DIR_SHEET['E17'] = bool_pool[0]
    DIR_SHEET['E17'].font = Font(color='000000')

    DirWorkBooK.save(new_path__)



def cover2(project_information: dict[str], new_path__: str):
    """
    :param project_information: 信息表[项目名称,监理单位,检验批部位,分项工程,检验批名称]
    :param new_path__: 新的文件名
    :return:

    """
    dir_path = TEMPLATES['封面']['报审表2']
    DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

    DIR_SHEET = DirWorkBooK[DirWorkBooK.sheetnames[0]]

    DIR_SHEET['E5'] = project_information.get('项目名称', '')
    DIR_SHEET['C7'] = project_information.get('监理单位', '')
    DIR_SHEET['F9'] = (project_information.get('检验批部位') + project_information.get('分项工程')
                       + project_information.get('检验批名称'))

    bool_pool = ['☑', '□']

    DIR_SHEET['E12'] = bool_pool[0]
    DIR_SHEET['E12'].font = Font(color='000000')
    DIR_SHEET['E13'] = bool_pool[1]
    DIR_SHEET['E13'].font = Font(color='000000')
    DIR_SHEET['E14'] = bool_pool[1]
    DIR_SHEET['E14'].font = Font(color='000000')
    DIR_SHEET['E15'] = bool_pool[1]
    DIR_SHEET['E15'].font = Font(color='000000')
    DIR_SHEET['E16'] = bool_pool[0]
    DIR_SHEET['E16'].font = Font(color='000000')

    DirWorkBooK.save(new_path__)


class CommonCheck(object):

    def __init__(self, project_information, _new_path_) -> None:

        self.sheet = None
        self.project_information = project_information

        dir_path = TEMPLATES['隐蔽验收']['隐蔽验收']

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=10)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=8)
        self.DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

        self.FORM()

        self.DirWorkBooK.save(_new_path_)

        self.DirWorkBooK.close()

    @staticmethod
    def offset_img(img:int, row:int, col:int):
        """精确设置图片位置，偏移量以万为单位进行微调吧，具体计算公式太麻烦了
        row column 的索引都是从0开始的,我这里要把图片插入到单元格B10
        """
        p2e = pixels_to_EMU
        h, w = img.height, img.width
        size = XDRPositiveSize2D(p2e(w), p2e(h))
        marker = AnchorMarker(col=col, colOff=70000, row=row, rowOff=70000)
        img.anchor = OneCellAnchor(_from=marker, ext=size)

    def save_to_excel(self, fig, row, col, DIR_SHEET):
        """把图片插入到excel文件中的指定位置
        插入到指定单元格然后向右偏移一点距离，目的是不让图片的边框和单元格的边框重合
        :param fig: 图片
        :return:
        """
        # 获取模板 excel 的操作对象
        # 根据 Sheet1 这个名字来获取 Sheet1
        img = Image(fig)
        # 设置图片的宽和高
        cnt = 81
        img.width, img.height = (5 * cnt, 3 * cnt)
        self.offset_img(img, row, col)
        # 将图片添加到excel中
        DIR_SHEET.add_image(img)

    def FORM(self):

        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        from check_project import CheckProject as CHECK_PROJECTS_Word

        CHECK_PROJECTS_Word = CHECK_PROJECTS_Word(
            self.project_information)  # 这里面加入检查内容的类

        if self.project_information.get('隐蔽验收类型'):  # 隐蔽验收类型(抬头写什么隐蔽类型)

            DIR_SHEET['G2'] = CHECK_PROJECTS[self.project_information['隐蔽验收类型']]['标题']

            DIR_SHEET['G2'].font = Font(size=17, bold=True, name='黑体')

        DIR_SHEET.merge_cells(
            start_row=8,
            start_column=14,
            end_column=23,
            end_row=11)

        if self.project_information.get('字体大小'):
            num = CHECK_PROJECTS[self.project_information['隐蔽验收类型']]['字体大小']
        else:
            num = 9
        if hasattr(CHECK_PROJECTS_Word,
                   CHECK_PROJECTS[self.project_information['隐蔽验收类型']]['检查内容']):
            word = getattr(CHECK_PROJECTS_Word,
                           CHECK_PROJECTS[self.project_information['隐蔽验收类型']]['检查内容'])()
        else:
            word = ''
        DIR_SHEET.cell(
            row=8, column=14).value = word
        DIR_SHEET.cell(
            row=8, column=14).font = Font(size=num, bold=True)
        DIR_SHEET.cell(row=8, column=14).alignment = Alignment(
            horizontal='left', vertical='top', wrapText=True)

        # 关于图片处理部分的
        if self.project_information.get('隐蔽验收图片', None):

            path = os.path.join(urls.TEMPLATES['隐蔽验收']['钢筋隐蔽验收图片'],
                                self.project_information['隐蔽验收图片'])  # 留下来作为后续的一个接口

            if Path(path).exists():
                DIR_SHEET.merge_cells(
                    start_row=12,
                    start_column=14,
                    end_column=23,
                    end_row=21)

                self.save_to_excel(path, row=11, col=13, DIR_SHEET=DIR_SHEET)

        # 主要的填写的内容入口
        if self.project_information.get(
                '项目名称', None) and self.project_information.get('单位工程', None):
            DIR_SHEET['D4'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        if self.project_information.get(
                '分部工程', None) and self.project_information.get('分项工程', None):
            DIR_SHEET['N4'] = self.project_information['分部工程'] + \
                '/' + self.project_information['子分部工程']

        DIR_SHEET['R4'] = self.project_information.get('项目负责人', '')
        DIR_SHEET['D5'] = self.project_information.get('施工单位', '')
        DIR_SHEET['N5'] = self.project_information.get('检验批部位', '')

        DIR_SHEET['C21'] = str_date(self.project_information.get('时间', ''))
        DIR_SHEET['S6'] = str_date(self.project_information.get('时间', ''))
        DIR_SHEET['R5'] = self.project_information.get('施工图号', '')
        DIR_SHEET['E6'] = CHECK_PROJECTS[self.project_information['隐蔽验收类型']]['验收规范']
        DIR_SHEET['R3'] = self.project_information['检验批编号']
        DIR_SHEET['R3'].font = Font(size=9, bold=True)

        if self.project_information.get('分项工程', None) and len(
                str(self.project_information['检验批编号'])) > 3:
            DIR_SHEET['N6'] = f"{self.project_information['分项工程']}/{self.project_information['检验批编号']}"
        elif self.project_information.get('分项工程'):
            DIR_SHEET['N6'] = f"{self.project_information['分项工程']}"
        elif self.project_information.get('检验批编号'):
            DIR_SHEET['N6'] = f"{self.project_information['检验批编号']}"

        CheckItemNum = len(
            CHECK_PROJECTS[self.project_information['隐蔽验收类型']]['检查项目'])
        for n in range(CheckItemNum):

            CheckDirItem = CHECK_PROJECTS[self.project_information['隐蔽验收类型']]['检查项目'][n]

            if len(CheckDirItem) > 22:
                DIR_SHEET.row_dimensions[8 + n].height = 30

            DIR_SHEET.cell(row=8 + n, column=2).value = CheckDirItem
            DIR_SHEET.cell(row=8 + n, column=2).alignment = Alignment(
                horizontal='left', vertical='center', wrapText=True)
            DIR_SHEET.cell(row=8 + n, column=2).font = Font(size=8)

            # 判断检查项目中是否存在特殊情况

            if CheckDirItem == '6、钢筋代换情况':
                DIR_SHEET.cell(row=8 + n, column=8).value = '/'
            else:
                DIR_SHEET.cell(row=8 + n, column=8).value = '符合要求'

        RemainderNum = 8 - CheckItemNum

        for n in range(RemainderNum):
            DIR_SHEET.unmerge_cells(
                start_row=8 + CheckItemNum + n, start_column=2, end_column=7, end_row=8 + CheckItemNum + n)
            DIR_SHEET.unmerge_cells(
                start_row=8 + CheckItemNum + n, start_column=8, end_column=13, end_row=8 + CheckItemNum + n)
            DIR_SHEET.merge_cells(
                start_row=8 + CheckItemNum + n, start_column=2, end_column=13, end_row=8 + CheckItemNum + n)

        for n in range(RemainderNum):
            key = f'B{8 + CheckItemNum + n}'
            DIR_SHEET[key].value = '( 以 下 空 白 )'
            DIR_SHEET[key].font = Font(bold=True, size=9)
            DIR_SHEET[key].alignment = Alignment(
                horizontal='center', vertical='center', wrap_text=True)


def judge_part(items, part):
    pattern = '|'.join(str(x) for x in items)
    if len(re.findall(pattern, part)) > 0:
        return True
    else:
        return False


class FormWork(object):

    def __init__(self, project_information, inport_sheetname) -> None:

        self.sheet = None

        self.inport_sheetname = inport_sheetname

        self.project_information = project_information

        self.project_information['分部工程'] = '主体结构'  # 或地基与基础

        self.project_information['子分部工程'] = '混凝土结构'  # 或基础

        self.project_information['分项工程'] = '模板'

        self.project_information['检验批名称'] = '模板安装'

        # 检验批容量
        # 后续需要修改的地方
        # self.CheckCapacity = f"{int(self.project_information['抹灰工程量'])}平方"

        dir_path = TEMPLATES['模板']['模板安装']

        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)

        # # 生成路径
        # # from urls import ThirdBasePath
        #
        # self.paths = ThirdBasePath(
        #     inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # # # 获取检验批编号
        # self.project_information['检验批编号'] = self.paths.finally_code()
        # # 生成报审表路径



        cover_name = r'E:\myapp2\OUTPUT\{self.project_information["检验批部位"]}{self.project_information["分项工程"]}报审表.xlsx'
        # cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表
        cover2(self.project_information, cover_name)

        # 写入检验批
        self.FROM1()

        self.FROM2()

        self.FORM3()

        # 生成保存文件的路径

        __new_path__ = '1.xlsx'

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        pass

    # 写入数据所在行

    def To_sheet(self, key, sheet, Range):

        number = self.project_information['模板检查数量']

        if number >= 10:

            for col in range(16, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])
                # print(sheet.cell(row=row,column=col).value)
        if number < 10:

            max_range = 26 - 10 + number

            for col in range(16, max_range):
                VALUE = random.randint(Range[0], Range[1])
                sheet.cell(
                    row=int(key[1:]), column=col).value = VALUE

            for col in range(max_range, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = '/'

    def To_shett2(self, key, sheet):

        for col in range(16, 26):
            sheet.cell(row=int(key[1:]), column=col).value = "/"

    def FROM1(self):

        # *********************主表******************************#

        DIR_SHEET = self.DirWorkBook['主表']

        # self.project_information
        # ****表头数据可以共用#

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['P5'] = self.project_information['分部工程']
        DIR_SHEET['F6'] = self.project_information['施工单位']
        DIR_SHEET['P6'] = self.project_information['项目负责人']
        DIR_SHEET['X6'] = self.project_information['模板检验批容量']
        DIR_SHEET['F7'] = self.project_information['分包单位']
        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']
        DIR_SHEET['X7'] = self.project_information['检验批部位']
        DIR_SHEET['X7'].font = Font(size=8)
        DIR_SHEET['W24'] = self.project_information['表格时间']
        DIR_SHEET['U3'] = self.project_information['最终的检验批编号']

        # ****表头数据可以共用#

        item_number = ['P{}'.format(x) for x in range(50)]
        for key1 in item_number:
            key2 = key1.replace('P', 'R')
            key3 = key1.replace('P', 'S')
            key4 = key1.replace('P', 'Z')

            if key1 == 'P10':

                DIR_SHEET[key1] = self.project_information['模板检查数量']
                DIR_SHEET[key2] = self.project_information['模板检查数量']
                # 这里可能需要重新修改
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P11':

                DIR_SHEET[key1] = self.project_information['模板检查数量']
                DIR_SHEET[key2] = self.project_information['模板检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P12':

                DIR_SHEET[key1] = self.project_information['模板检查数量']
                DIR_SHEET[key2] = self.project_information['模板检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P13':

                DIR_SHEET[key1] = self.project_information['模板检查数量']
                DIR_SHEET[key2] = self.project_information['模板检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P14':

                DIR_SHEET[key1] = self.project_information['模板检查数量']
                DIR_SHEET[key2] = self.project_information['模板检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P15':

                DIR_SHEET[key1] = self.project_information['模板检查数量']
                DIR_SHEET[key2] = self.project_information['模板检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P16':

                if judge_part(
                        ['板'],
                        self.project_information['检验批部位']) and judge_part(
                    ['底板'],
                        self.project_information['检验批部位']) is False:
                    DIR_SHEET[key1] = self.project_information['模板检查数量']
                    DIR_SHEET[key2] = self.project_information['模板检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = '/'

            if key1 == 'P17':

                DIR_SHEET[key3] = '/'
                DIR_SHEET[key4] = '/'

            elif key1 == 'P18':
                if judge_part(['管墩', '设备', '间隔堤', '柱'], self.project_information['检验批部位']
                              ) or self.project_information['预留洞'] or self.project_information['预埋件']:
                    DIR_SHEET[key1] = self.project_information['模板检查数量']
                    DIR_SHEET[key2] = self.project_information['模板检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key4] = "合格"

            elif key1 == 'P19':

                DIR_SHEET[key1] = self.project_information['模板检查数量']
                DIR_SHEET[key2] = self.project_information['模板检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key4] = "合格"

            if key1 == 'P20':

                if judge_part(['预制'], self.project_information['检验批部位']):
                    # print(self.judge_part(setting.ITEM8,self.project_information['检验批部位']))

                    DIR_SHEET[key1] = self.project_information['模板检查数量']
                    DIR_SHEET[key2] = self.project_information['模板检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = "/"

    def FROM2(self):
        DIR_SHEET2 = self.DirWorkBook['检查记录-1']

        DIR_SHEET2['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET2['S6'] = self.project_information['最终的检验批编号']

        ITEM1 = ['L{}'.format(x) for x in range(50)]

        for key in ITEM1:
            # print(key)
            key2 = key.replace("L", "Z")

            if key == 'L8':
                if judge_part(
                        items=['梁'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [1, 4]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'
                    # print('完成')

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L9':
                if judge_part(
                        items=['板'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [1, 4]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L10':
                if judge_part(
                        items=['设备'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [1, 3]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L11':
                if judge_part(
                        items=['设备'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 3]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            # 插筋
            elif key == 'L12':
                if judge_part(
                        items=['插筋', '构造柱'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 5]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L13':
                if judge_part(
                        items=['插筋', '构造柱'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 10]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            # 预埋螺栓
            elif key == 'L14':
                if judge_part(
                        items=['预埋螺栓', '墩'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 2]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L15':
                if judge_part(
                        items=['预埋螺栓', '墩'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 10]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            # 预留洞

            elif key == 'L16':
                if judge_part(
                        items=['预留洞口', '堤'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 10]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L17':
                if judge_part(
                        items=['预留洞口', '堤'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 10]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            # 4.2.10条

            ##

            elif key == 'L18':
                DIR_SHEET2[key] = self.project_information['检验批部位']
                DIR_SHEET2[key].font = Font(size=8)
                DIR_Range = [0, 5]
                for n, value in enumerate(self.project_information['轴线偏位数据']):
                    DIR_SHEET2.cell(row=18, column=16 + n, value=value)
                DIR_SHEET2[key2] = '合格'
                time.sleep(0.1)

            elif key == 'L19':
                if judge_part(['板', '梁'], self.project_information['检验批部位']) is True and judge_part(
                        ['底板'], self.project_information['检验批部位']) is False:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 5]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'
                    time.sleep(0.1)

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            # 模板内部尺寸

            elif key == 'L20':
                if judge_part(
                        items=['基础'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 10]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L21':
                if judge_part(
                        items=[
                            '柱',
                            '墙',
                            '梁',
                            '墩'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [-5, 5]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L22':
                if judge_part(
                        items=['楼梯'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [-5, 5]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L23':
                if judge_part(
                        items=[
                            '柱',
                            '墙'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 8]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L24':

                DIR_SHEET2[key] = '/'
                DIR_SHEET2[key2] = '/'
                start_row = int(key[1:])
                DIR_SHEET2.merge_cells(
                    start_row=start_row,
                    start_column=16,
                    end_column=25,
                    end_row=start_row)
                key3 = f"P{start_row}"
                DIR_SHEET2[key3] = '/'

            elif key == 'L25':
                if judge_part(
                        items=[
                            '柱',
                            '墙'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 2]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L26':
                if judge_part(
                        items=[
                            '柱',
                            '墙'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = Font(size=8)
                    DIR_Range = [0, 5]
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L27':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '梁',
                                '板'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET2[key] = self.project_information['检验批部位']
                        DIR_SHEET2[key].font = Font(size=8)
                        DIR_SHEET2[key].font = Font(size=8)
                        DIR_Range = [-4, 4]
                        self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L28':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '薄腹梁',
                                '桁架'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET2[key] = self.project_information['检验批部位']
                        DIR_SHEET2[key].font = Font(size=8)
                        DIR_Range = [-8, 8]
                        self.To_sheet(key, DIR_SHEET2, DIR_Range)
                    DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L29':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=['柱'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET2[key] = self.project_information['检验批部位']
                        DIR_SHEET2[key].font = Font(size=8)
                        DIR_Range = [-10, 0]
                        self.To_sheet(key, DIR_SHEET2, DIR_Range)
                        DIR_SHEET2[key2] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            elif key == 'L30':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=['柱'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET2[key] = self.project_information['检验批部位']
                        DIR_SHEET2[key].font = Font(size=8)
                        DIR_Range = [0, -5]
                        self.To_sheet(key, DIR_SHEET2, DIR_Range)
                        DIR_SHEET2[key2] = '合格'
                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET2[key3] = '/'

            else:
                # print('完成')
                pass

        # *********************检查记录——1************************#

        # *********************检查记录——2************************#

    def FORM3(self):

        DIR_SHEET3 = self.DirWorkBook['检查记录-2']

        DIR_SHEET3['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET3['W28'] = self.project_information['表格时间']

        DIR_SHEET3['S6'] = self.project_information['最终的检验批编号']

        ITEM_NYMBER2 = ['L{}'.format(x) for x in range(50)]
        for key in ITEM_NYMBER2:
            key2 = key.replace("L", "Z")
            if key == 'L8':

                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '板',
                                '墙'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)

                        DIR_Range = [-5, 0]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L9':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '梁',
                                '薄腹梁',
                                '桁架'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [-5, 2]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L10':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=['板'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [-3, 2]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L11':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=['墙'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [-5, 0]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L12':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '梁',
                                '薄腹梁',
                                '桁架',
                                '柱'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [-5, 2]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L13':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '梁',
                                '板',
                                '柱'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [0, 15]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L14':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '墙',
                                '薄腹梁',
                                '桁架'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [0, 15]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'
            if key == 'L15':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET3[key] = self.project_information['检验批部位']
                    DIR_SHEET3[key].font = Font(size=8)
                    DIR_Range = [0, 3]
                    self.To_sheet(key, DIR_SHEET3, DIR_Range)
                    DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'
            if key == 'L16':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    DIR_SHEET3[key] = self.project_information['检验批部位']
                    DIR_SHEET3[key].font = Font(size=8)
                    DIR_Range = [0, 1]
                    self.To_sheet(key, DIR_SHEET3, DIR_Range)
                    DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L17':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=['板'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [0, 7]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L18':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=['墙'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [0, 5]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L19':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '墙',
                                '板'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [0, 5]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'

            if key == 'L20':
                if judge_part(
                        items=['预制'],
                        part=self.project_information['检验批部位']):
                    if judge_part(
                            items=[
                                '薄腹梁',
                                '桁架',
                                '梁'],
                            part=self.project_information['检验批部位']):
                        DIR_SHEET3[key] = self.project_information['检验批部位']
                        DIR_SHEET3[key].font = Font(size=8)
                        DIR_Range = [-3, 3]
                        self.To_sheet(key, DIR_SHEET3, DIR_Range)
                        DIR_SHEET3[key2] = '合格'

                else:
                    DIR_SHEET3[key] = '/'
                    DIR_SHEET3[key2] = '/'
                    start_row = int(key[1:])
                    DIR_SHEET3.merge_cells(
                        start_row=start_row,
                        start_column=16,
                        end_column=25,
                        end_row=start_row)
                    key3 = f"P{start_row}"
                    DIR_SHEET3[key3] = '/'


# 位置和尺寸偏差


class LocationPart(object):

    def __init__(self, project_information, _new_path_) -> None:
        """
        param project_information: 信息表
        param new_path_: 新的文件名称
        """

        self.project_information = project_information

        dir_path = TEMPLATES['现浇结构']['位置和尺寸偏差']

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=8)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=10)

        self.DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

        self.FROM1()

        self.FROM2()

        self.DirWorkBooK.save(_new_path_)

        pass

    # 部位判别器

    # 写入数据所在行

    def To_sheet(self, key, sheet, Range):

        if self.project_information['混凝土的检查数量'] >= 10:

            for col in range(16, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])
                # print(sheet.cell(row=row,column=col).value)
        if self.project_information['混凝土的检查数量'] < 10:

            max_range = 26 - 10 + self.project_information['混凝土的检查数量']

            for col in range(16, max_range):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])

    # ***********************混凝土*******************************#
    # ****** ***位置和尺寸偏差检验批质量验收记录******************************#

    def FROM1(self):
        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        RECORD = self.project_information['检查记录']

        # ****表头数据可以共用#
        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['P5'] = self.project_information['分部工程']
        DIR_SHEET['F6'] = self.project_information['施工单位']
        DIR_SHEET['P6'] = self.project_information['项目负责人']
        DIR_SHEET['X6'] = self.project_information['检验批容量']
        DIR_SHEET['F7'] = self.project_information['分包单位']
        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']
        DIR_SHEET['X7'] = self.project_information['检验批部位']
        DIR_SHEET['X5'] = self.project_information['分项工程']
        DIR_SHEET['W34'] = self.project_information['表格时间']

        # ****表头数据可以共用#

        # 模板
        ITEM_NYMBER = ['P{}'.format(x) for x in range(50)]

        for key1 in ITEM_NYMBER:
            key2 = key1.replace('P', 'R')
            key3 = key1.replace('P', 'S')
            key4 = key1.replace('P', 'Z')

            if key1 == 'P11':
                DIR_SHEET[key1] = self.project_information['检验批容量']
                DIR_SHEET[key2] = self.project_information['检验批容量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if judge_part(['设备', '设备基础', '管墩'],
                          self.project_information['检验批部位']):
                if key1 == 'P21':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P22':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P23':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P24':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P25':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P26':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P27':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P28':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P29':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P30':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"
            else:
                if key1 == 'P13':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P14':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P15':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P16':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                if key1 == 'P17':
                    if judge_part(
                            ['电梯井'], self.project_information['检验批部位']):
                        DIR_SHEET[key1] = self.project_information['检验批容量']
                        DIR_SHEET[key2] = self.project_information['检验批容量']
                        DIR_SHEET[key3] = RECORD
                        DIR_SHEET[key3].font = self.Fontstyle
                        DIR_SHEET[key4] = "合格"

                if key1 == 'P18':
                    DIR_SHEET[key1] = self.project_information['检验批容量']
                    DIR_SHEET[key2] = self.project_information['检验批容量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"
                if key1 == 'P19':

                    if self.project_information['预埋件']:
                        DIR_SHEET[key1] = self.project_information['检验批容量']
                        DIR_SHEET[key2] = self.project_information['检验批容量']
                        DIR_SHEET[key3] = RECORD
                        DIR_SHEET[key3].font = self.Fontstyle
                        DIR_SHEET[key4] = "合格"

                if key1 == 'P20':
                    if self.project_information['预埋件']:
                        DIR_SHEET[key1] = self.project_information['检验批容量']
                        DIR_SHEET[key2] = self.project_information['检验批容量']
                        DIR_SHEET[key3] = RECORD
                        DIR_SHEET[key3].font = self.Fontstyle
                        DIR_SHEET[key4] = "合格"

                pass

    def FROM2(self):

        DIR_SHEET1 = self.DirWorkBooK[self.DirWorkBooK.sheetnames[1]]

        DIR_SHEET1['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET1['W31'] = self.project_information['表格时间']

        ITEM_NYMBER2 = ['L{}'.format(x) for x in range(50)]

        for key in ITEM_NYMBER2:
            key2 = key.replace('L', 'Z')

            if judge_part(['基础'], self.project_information['检验批部位']) and judge_part(
                    ['底板', '垫层'], self.project_information['检验批部位']) is False:

                if key == 'L9':
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)
            elif judge_part(['底板', '垫层'], self.project_information['检验批部位']):
                if key == 'L8':
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 15]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L10':
                if judge_part(['柱', '墙', '梁'],
                              self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 15]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)
            elif key == 'L11':
                if judge_part(['层', '柱', '墙', '梁', '板'],
                              self.project_information['检验批部位']):
                    if self.project_information['层高'] <= 6:
                        DIR_SHEET1[key] = self.project_information['检验批部位']
                        DIR_SHEET1[key2] = '合格'
                        DIR_Range = [0, 15]  # 起拱的范围
                        self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L12':
                if judge_part(['层', '柱', '墙', '梁', '板'],
                              self.project_information['检验批部位']):
                    if self.project_information['层高'] > 6:
                        DIR_SHEET1[key] = self.project_information['检验批部位']
                        DIR_SHEET1[key2] = '合格'
                        DIR_Range = [0, 15]  # 起拱的范围
                        self.To_sheet(key, DIR_SHEET1, DIR_Range)
            elif key == 'L14':
                if judge_part(['层', '柱', '墙'],
                              self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [-10, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L15':
                if judge_part(['屋面'], self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [-30, 30]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L16':

                if judge_part(['基础'], self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [-10, 15]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L17':
                if judge_part(['柱'], self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [-5, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L18':
                if judge_part(['梁'], self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [-5, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L19':
                if judge_part(['板'], self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key].font = self.Fontstyle

                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [-5, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L20':
                if judge_part(['墙  '], self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key].font = self.Fontstyle
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [-5, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L21':
                if judge_part(['楼梯'], self.project_information['检验批部位']):
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [-5, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)
            elif judge_part(['电梯井'], self.project_information['检验批部位']):
                if key == 'L22':

                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)
                elif key == 'L23':

                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key].font = self.Fontstyle
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 25]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

            elif key == 'L24':

                DIR_SHEET1[key] = self.project_information['检验批部位']
                DIR_SHEET1[key].font = self.Fontstyle
                DIR_SHEET1[key2] = '合格'
                DIR_Range = [0, 8]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET1, DIR_Range)

            if self.project_information['预埋件']:

                if key == 'L25':

                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key].font = self.Fontstyle
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

                elif key == 'L26':
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key].font = self.Fontstyle
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 5]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)
                elif key == 'L27':
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key].font = self.Fontstyle
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 5]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)

                elif key == 'L28':

                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key].font = self.Fontstyle
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)
            if self.project_information['预留洞']:
                if key == 'L29':
                    DIR_SHEET1[key] = self.project_information['检验批部位']
                    DIR_SHEET1[key].font = self.Fontstyle
                    DIR_SHEET1[key2] = '合格'
                    DIR_Range = [0, 15]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET1, DIR_Range)


# 钢筋连接
class RebarConnection(object):

    # 字体大小

    def __init__(self, project_information, new_path_) -> None:
        """

        param project_information: 信息记录表
        param new_path_: 新文件的名称
        """

        dir_path = TEMPLATES['钢筋']['钢筋连接']
        self.project_information = project_information

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=8)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=10)

        self.new_path_ = new_path_

        self.DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

        self._FROM1_()
        self._FROM2_()

        self.DirWorkBooK.save(self.new_path_)

        pass

    # 部位判别器

    # 写入数据所在行

    def To_sheet(self, key, sheet, Range):

        if self.project_information['钢筋连接检查数量'] >= 10:

            for col in range(16, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])
                # print(sheet.cell(row=row,column=col).value)
        if self.project_information['钢筋连接检查数量'] < 10:

            max_range = 26 - 10 + self.project_information['钢筋连接检查数量']

            for col in range(16, max_range):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])

    # ***********************钢筋*******************************#
    # *********************钢筋安装(主表)
    def _FROM1_(self):

        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        DIR_SHEET['U3'] = self.project_information['最终的检验批编号']

        # self.project_information

        # ****表头数据可以共用#

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['P5'] = self.project_information['分部工程']
        DIR_SHEET['F6'] = self.project_information['施工单位']
        DIR_SHEET['P6'] = self.project_information['项目负责人']
        DIR_SHEET['X6'] = self.project_information['钢筋连接检验批容量']
        DIR_SHEET['F7'] = self.project_information['分包单位']
        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']
        DIR_SHEET['X7'] = self.project_information['检验批部位']
        DIR_SHEET['X7'].font = self.Fontstyle
        DIR_SHEET['X5'] = self.project_information['分项工程']
        DIR_SHEET['W28'] = self.project_information['表格时间']

        # ****表头数据可以共用#

        # 模板
        item_number = ['P{}'.format(x) for x in range(50)]

        for key1 in item_number:
            key2 = key1.replace('P', 'R')
            key3 = key1.replace('P', 'S')
            key4 = key1.replace('P', 'Z')

            if key1 == 'P11':  # 判断是否存在其他的连接方式
                DIR_SHEET[key1] = '全'
                DIR_SHEET[key2] = ' '
                DIR_SHEET[key3] = '该部位采用绑扎连接,符合设计及规范要求'
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P12':
                if self.project_information['机械连接'] or self.project_information['焊接连接']:
                    if self.project_information['机械连接']:
                        DIR_SHEET[key3] = '该部位采用机械连接,符合设计及规范要求'

                    if self.project_information['焊接连接']:
                        DIR_SHEET[key3] = '该部位采用焊接连接,符合设计及规范要求'
                    else:
                        DIR_SHEET[key3] = '/'

                    DIR_SHEET[key1] = '全'
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"
                else:
                    DIR_SHEET[key1] = ' '
                    DIR_SHEET[key2] = ' '
                    DIR_SHEET[key3] = '/'

                    DIR_SHEET[key4] = "/"

            if key1 == 'P14':
                if self.project_information['螺纹接头']:
                    DIR_SHEET[key1] = '全'
                    DIR_SHEET[key2] = ' '
                    DIR_SHEET[key3] = '该部位采用螺纹接头,符合设计及规范要求'
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ' '
                    DIR_SHEET[key2] = ' '
                    DIR_SHEET[key3] = '/'

                    DIR_SHEET[key4] = "/"

            if key1 == 'P16':
                DIR_SHEET[key1] = self.project_information['钢筋连接检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋连接检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P17':

                if self.project_information['机械连接'] or self.project_information['焊接连接']:
                    DIR_SHEET[key1] = self.project_information['钢筋连接检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋连接检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ' '
                    DIR_SHEET[key2] = ' '
                    DIR_SHEET[key3] = '/'

                    DIR_SHEET[key4] = "/"

            if key1 == 'P19':

                if self.project_information['机械连接'] or self.project_information['焊接连接']:
                    DIR_SHEET[key1] = self.project_information['钢筋连接检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋连接检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ' '
                    DIR_SHEET[key2] = ' '
                    DIR_SHEET[key3] = '/'

                    DIR_SHEET[key4] = "/"

            if key1 == 'P21':

                if self.project_information['绑扎连接']:
                    DIR_SHEET[key1] = self.project_information['钢筋连接检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋连接检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ' '
                    DIR_SHEET[key2] = ' '
                    DIR_SHEET[key3] = '/'

                    DIR_SHEET[key4] = "/"

            if key1 == 'P23':

                if judge_part(['梁', '柱'], self.project_information['检验批部位']
                              ) and self.project_information['绑扎连接']:
                    DIR_SHEET[key1] = self.project_information['钢筋连接检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋连接检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ' '
                    DIR_SHEET[key2] = ' '
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = "/"

    def _FROM2_(self):
        DIR_SHEET2 = self.DirWorkBooK[self.DirWorkBooK.sheetnames[1]]

        DIR_SHEET2['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET2['W25'] = self.project_information['表格时间']
        DIR_SHEET2['S6'] = self.project_information['最终的检验批编号']

        ITEM_NYMBER2 = ['L{}'.format(x) for x in range(50)]

        for key in ITEM_NYMBER2:
            key2 = key.replace("L", 'P')
            key3 = key.replace('L', 'Z')

            if key == 'L8':
                if self.project_information['螺纹接头']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key] = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L9':
                if self.project_information['挤压接头']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key] = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L10':
                if self.project_information['闪光对焊']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key] = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L10':
                if self.project_information['闪光对焊']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key] = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L11':
                if self.project_information['闪光对焊']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key] = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L12':
                if self.project_information['电弧焊']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key] = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L13':
                if self.project_information['电渣压力焊']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L14':
                if self.project_information['气压焊']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L15':
                if self.project_information['预埋件']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L16':
                if self.project_information['机械连接']:

                    if judge_part(['梁', '柱', '基础'],
                                  self.project_information['检验批部位']):
                        DIR_SHEET2[key] = self.project_information['检验批部位']
                        DIR_SHEET2[key].font = self.Fontstyle
                        DIR_SHEET2[key2] = self.project_information['检查记录']
                        DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L17':
                if self.project_information['机械连接']:
                    if judge_part(['墙', '柱', '板'],
                                  self.project_information['检验批部位']):
                        DIR_SHEET2[key] = self.project_information['检验批部位']
                        DIR_SHEET2[key] = self.Fontstyle
                        DIR_SHEET2[key2] = self.project_information['检查记录']
                        DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L18':
                if self.project_information['机械连接']:
                    if judge_part(
                            ['地下室'], self.project_information['检验批部位']):
                        DIR_SHEET2[key] = self.project_information['检验批部位']
                        DIR_SHEET2[key].font = self.Fontstyle
                        DIR_SHEET2[key2] = self.project_information['检查记录']
                        DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L19':
                if self.project_information['绑扎连接']:
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L20':

                if self.project_information['绑扎连接']:

                    if judge_part(['梁', '板', '墙'],
                                  self.project_information['检验批部位']):
                        DIR_SHEET2[key] = self.project_information['检验批部位']
                        DIR_SHEET2[key].font = self.Fontstyle
                        DIR_SHEET2[key2] = self.project_information['检查记录']
                        DIR_SHEET2[key3] = '合格'

                    else:
                        DIR_SHEET2[key] = '/'
                        DIR_SHEET2[key2] = '/'
                        DIR_SHEET2[key3] = '/'
                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L21':

                if judge_part(
                        ['梁', '柱'], self.project_information['检验批部位']):
                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L22':

                if judge_part(['梁', '柱'], self.project_information['检验批部位']):

                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L23':

                if judge_part(['梁', '柱'], self.project_information['检验批部位']):

                    DIR_SHEET2[key] = self.project_information['检验批部位']
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = self.project_information['检查记录']
                    DIR_SHEET2[key3] = '合格'

                else:
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'


# 钢筋安装


class RebarInstallation(object):

    def __init__(self, project_information, new_path_) -> None:

        self.project_information = project_information

        self.new_path_ = new_path_
        self.dir_path = TEMPLATES['钢筋']['钢筋安装']
        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=8)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=10)

        self.part_name = self.project_information['检验批部位']

        self.DirWorkBooK = openpyxl.load_workbook(self.dir_path)

        self.FROM1()

        if judge_part(items=['梁', '柱', '基础'], part=self.part_name):

            self.FROM2()

        else:
            DIR_SHEET2 = self.DirWorkBooK['检查记录（梁、柱、独立基础）']
            self.DirWorkBooK.remove(DIR_SHEET2)

        if judge_part(items=['墙', '板'], part=self.part_name):

            self.FORM3()
        else:
            DIR_SHEET2 = self.DirWorkBooK['检查记录（墙、板）']
            self.DirWorkBooK.remove(DIR_SHEET2)

        self.DirWorkBooK.save(new_path_)

        pass

    # 部位判别器

    # 写入数据所在行

    def To_sheet(self, key, sheet, Range):

        if self.project_information['钢筋安装检查数量'] >= 10:

            for col in range(16, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])
                # print(sheet.cell(row=row,column=col).value)
        if self.project_information['钢筋安装检查数量'] < 10:

            max_range = 26 - 10 + self.project_information['钢筋安装检查数量']

            for col in range(16, max_range):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])

            for col in range(max_range, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = '/'

                # print(sheet.cell(row=row,column=col).value)

    # ***********************钢筋*******************************#
    # *********************钢筋安装(主表)******************************#

    def FROM1(self):

        DIR_SHEET = self.DirWorkBooK['主表']

        # self.project_information

        RECORD = self.project_information['检查记录'] = '检查{}处，符合要求{}处，满足设计及规范要求'.format(
            self.project_information['钢筋安装检查数量'], self.project_information['钢筋安装检查数量'])

        # ****表头数据可以共用#

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['P5'] = self.project_information['分部工程']
        DIR_SHEET['F6'] = self.project_information['施工单位']
        DIR_SHEET['P6'] = self.project_information['项目负责人']
        DIR_SHEET['X6'] = self.project_information['钢筋安装检验批容量']
        DIR_SHEET['F7'] = self.project_information['分包单位']
        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']
        DIR_SHEET['X7'] = self.project_information['检验批部位']
        DIR_SHEET['X7'].font = self.Fontstyle
        DIR_SHEET['W26'] = self.project_information['表格时间']
        DIR_SHEET['X5'] = self.project_information['分项工程']
        DIR_SHEET['U3'] = self.project_information['最终的检验批编号']

        # ****表头数据可以共用#

        item_number = ['P{}'.format(x) for x in range(50)]
        for key1 in item_number:

            key2 = key1.replace('P', 'R')
            key3 = key1.replace('P', 'S')
            key4 = key1.replace('P', 'Z')

            if key1 == 'P11':

                DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P12':

                DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P14':

                DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P15':

                DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P15':

                DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P16':

                DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P17':

                if judge_part(items=['基础'], part=self.part_name):

                    DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"
                else:
                    DIR_SHEET[key1] = ''
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = "/"

            elif key1 == 'P18':

                if judge_part(items=['柱', '梁'], part=self.part_name):

                    DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"
                else:
                    DIR_SHEET[key1] = ''
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = "/"

            elif key1 == 'P19':

                if judge_part(items=['板', '墙', '壳'], part=self.part_name):

                    DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ''
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = "/"

            elif key1 == 'P20':

                DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P21':

                DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            elif key1 == 'P22':

                if judge_part(
                        items=[
                            '设备',
                            '设备基础',
                            '柱'],
                        part=self.part_name):

                    DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ''
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = "/"

            elif key1 == 'P23':

                if judge_part(
                        items=[
                            '设备',
                            '设备基础',
                            '柱'],
                        part=self.part_name):

                    DIR_SHEET[key1] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋安装检查数量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ''
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = "/"

    # ***************************钢筋安装(检查记录（梁、柱、独立基础）)*******#

    def FROM2(self):

        DIR_SHEET2 = self.DirWorkBooK['检查记录（梁、柱、独立基础）']
        DIR_SHEET2['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET2['W23'] = self.project_information['表格时间']
        DIR_SHEET2['S6'] = self.project_information['最终的检验批编号']

        # ****表头数据可以共用#

        # 中间的检验批数据

        ITEM_NYMBER2 = ['L{}'.format(x) for x in range(50)]
        for key in ITEM_NYMBER2:
            key2 = key.replace('L', 'Z')
            key3 = key.replace('L', 'P')

            if key == 'L8':
                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-10, 10]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            if key == 'L9':
                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-5, 5]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            if key == 'L10':
                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-20, 0]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            if key == 'L11':
                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-10, 10]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            if key == 'L12':
                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-5, 5]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            if key == 'L13':

                if judge_part(items=['基础'], part=self.part_name):
                    DIR_SHEET2[key] = self.part_name
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = '合格'
                    DIR_Range = [-10, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)

                else:
                    row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=row, end_row=row, start_column=16, end_column=25)
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L14':

                if judge_part(items=['柱', '梁'], part=self.part_name):
                    DIR_SHEET2[key] = self.part_name
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = '合格'
                    DIR_Range = [-10, 10]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                else:
                    row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=row, end_row=row, start_column=16, end_column=25)
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            if key == 'L15':

                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-20, 20]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            elif key == 'L16':

                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [0, 20]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            elif key == 'L17':

                if judge_part(['管墩', '设备', '间隔堤', '柱', '电缆沟'], self.project_information['检验批部位']
                              ) or self.project_information['预留洞'] or self.project_information['预埋件']:
                    DIR_SHEET2[key] = self.part_name
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = '合格'
                    DIR_Range = [0, 5]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                else:
                    row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=row, end_row=row, start_column=16, end_column=25)
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

            elif key == 'L18':

                if judge_part(['管墩', '设备', '间隔堤', '柱', '电缆沟'], self.project_information['检验批部位']
                              ) or self.project_information['预留洞'] or self.project_information['预埋件']:
                    DIR_SHEET2[key] = self.part_name
                    DIR_SHEET2[key].font = self.Fontstyle
                    DIR_SHEET2[key2] = '合格'
                    DIR_Range = [0, 3]  # 起拱的范围
                    self.To_sheet(key, DIR_SHEET2, DIR_Range)
                else:
                    row = int(key[1:])
                    DIR_SHEET2.merge_cells(
                        start_row=row, end_row=row, start_column=16, end_column=25)
                    DIR_SHEET2[key] = '/'
                    DIR_SHEET2[key2] = '/'
                    DIR_SHEET2[key3] = '/'

    def FORM3(self):

        DIR_SHEET2 = self.DirWorkBooK['检查记录（墙、板）']

        DIR_SHEET2['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET2['W23'] = self.project_information['表格时间']
        DIR_SHEET2['S6'] = self.project_information['最终的检验批编号']

        ITEM_NYMBER2 = ['L{}'.format(x) for x in range(50)]

        for key in ITEM_NYMBER2:
            key2 = key.replace('L', 'Z')

            if key == 'L8':

                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-10, 10]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            elif key == 'L9':

                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-20, 20]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            elif key == 'L10':

                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-20, 0]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            elif key == 'L11':

                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [-10, 10]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            elif key == 'L12':

                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [0, 5]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)

            elif key == 'L13':

                DIR_SHEET2[key] = self.part_name
                DIR_SHEET2[key].font = self.Fontstyle
                DIR_SHEET2[key2] = '合格'
                DIR_Range = [0, 3]  # 起拱的范围
                self.To_sheet(key, DIR_SHEET2, DIR_Range)


# 钢筋原材料


class ReinMaterials(object):

    def __init__(self, project_information, new_path_) -> None:

        self.project_information = project_information

        self.dir_path = TEMPLATES['钢筋']['钢筋原材料']

        self.DirWorkBooK = openpyxl.load_workbook(self.dir_path)

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=8)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=10)

        self.new_path_ = new_path_

        self.FORM1()

        self.DirWorkBooK.save(self.new_path_)
        pass

    # 写入数据所在行

    # ***********************钢筋*******************************#
    # *********************钢筋安装(主表)******************************#

    def FORM1(self):
        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        # self.project_information
        RECORD = '检查{1}处，符合要求{1}处，满足设计及规范要求'.format(
            self.project_information['钢筋原材料检查数量'],
            self.project_information['钢筋原材料检查数量'])

        # ****表头数据可以共用#

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['P5'] = self.project_information['分部工程']
        DIR_SHEET['F6'] = self.project_information['施工单位']
        DIR_SHEET['P6'] = self.project_information['项目负责人']
        DIR_SHEET['X6'] = self.project_information['钢筋原材料检验批容量']
        DIR_SHEET['F7'] = self.project_information['分包单位']
        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']
        DIR_SHEET['X7'] = self.project_information['检验批部位']
        DIR_SHEET['X7'].font = self.Fontstyle
        DIR_SHEET['X5'] = self.project_information['分项工程']
        DIR_SHEET['W19'] = self.project_information['表格时间']
        DIR_SHEET['U3'] = self.project_information['最终的检验批编号']

        # ****表头数据可以共用#

        # 模板
        ITEM_NYMBER = ['P{}'.format(x) for x in range(50)]

        for key1 in ITEM_NYMBER:

            key2 = key1.replace('P', 'R')
            key3 = key1.replace('P', 'S')
            key4 = key1.replace('P', 'Z')

            if key1 == 'P10':
                DIR_SHEET[key1] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P11':
                DIR_SHEET[key1] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P12':
                DIR_SHEET[key1] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P13':
                DIR_SHEET[key1] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P14':
                DIR_SHEET[key1] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋原材料检查数量']
                DIR_SHEET[key3] = RECORD
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P15':
                if self.project_information['机械连接'] or self.project_information['预埋件']:
                    DIR_SHEET[key1] = self.project_information['钢筋原材料检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋原材料检查数量']
                    DIR_SHEET[key3] = RECORD
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"
                else:
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key4] = '/'


# 钢筋加工


class ReinProcess(object):

    # 字体大小

    def __init__(self, project_information, new_path_) -> None:

        self.project_information = project_information

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=8)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=10)

        self.new_path_ = new_path_

        self.dir_path = TEMPLATES['钢筋']['钢筋加工']
        self.DirWorkBooK = openpyxl.load_workbook(self.dir_path)

        self.DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        self.FROM1()

        self.FROM2()

        self.DirWorkBooK.save(self.new_path_)

        pass

    # 部位判别器

    # 写入数据所在行

    def To_sheet(self, key, sheet, Range):

        if self.project_information['钢筋原材料检查数量'] >= 10:

            for col in range(16, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])
                # print(sheet.cell(row=row,column=col).value)
        if self.project_information['钢筋原材料检查数量'] < 10:

            max_range = 26 - 10 + self.project_information['钢筋原材料检查数量']

            for col in range(16, max_range):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])
            # print(sheet.cell(row=row,column=col).value)

            for col in range(max_range, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = '/'

    # ***********************钢筋*******************************#
    # *********************钢筋安装(主表)******************************#

    def FROM1(self):

        # self.project_information

        self.project_information['检查记录'] = self.project_information['检查记录']

        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        # ****表头数据可以共用#

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['P5'] = self.project_information['分部工程']
        DIR_SHEET['F6'] = self.project_information['施工单位']
        DIR_SHEET['P6'] = self.project_information['项目负责人']
        DIR_SHEET['X6'] = self.project_information['钢筋加工检验批容量']
        DIR_SHEET['F7'] = self.project_information['分包单位']
        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']
        DIR_SHEET['X7'] = self.project_information['检验批部位']
        DIR_SHEET['X7'].font = self.Fontstyle
        DIR_SHEET['W28'] = self.project_information['表格时间']
        DIR_SHEET['X5'] = self.project_information['分项工程']
        DIR_SHEET['U3'] = self.project_information['最终的检验批编号']

        # ****表头数据可以共用#

        # 模板
        ITEM_NYMBER = ['P{}'.format(x) for x in range(50)]

        for key1 in ITEM_NYMBER:

            key2 = key1.replace('P', 'R')
            key3 = key1.replace('P', 'S')
            key4 = key1.replace('P', 'Z')

            if key1 == 'P11':
                DIR_SHEET[key1] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P13':
                DIR_SHEET[key1] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P15':
                DIR_SHEET[key1] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P17':
                if self.project_information['是否存在盘螺']:
                    DIR_SHEET[key1] = self.project_information['钢筋加工检查数量']
                    DIR_SHEET[key2] = self.project_information['钢筋加工检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

            if key1 == 'P19':
                DIR_SHEET[key1] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P21':
                DIR_SHEET[key1] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P23':
                DIR_SHEET[key1] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key2] = self.project_information['钢筋加工检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

        # ----------------------表二---------------#

    def FROM2(self):

        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[1]]
        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['W23'] = self.project_information['表格时间']
        DIR_SHEET['S6'] = self.project_information['最终的检验批编号']

        ITEM_NYMBER = ['L{}'.format(x) for x in range(50)]

        for key in ITEM_NYMBER:
            key2 = key.replace('L', 'P')
            key3 = key.replace('L', 'Z')

            if key == 'L8':
                if judge_part(
                        items=[
                            'HPB',
                        ],
                        part=self.project_information['钢筋的强度']):

                    DIR_SHEET[key] = self.project_information['检验批部位']
                    DIR_SHEET[key].font = self.Fontstyle
                    DIR_SHEET[key2] = '符合要求'
                    DIR_SHEET[key3] = '合格'
                else:

                    DIR_SHEET[key] = '/'
                    DIR_SHEET[key2] = '/'
                    DIR_SHEET[key3] = '/'

            if key == 'L9':
                if judge_part(
                        items=[
                            'HRB400'
                        ],
                        part=self.project_information['钢筋的强度']):

                    DIR_SHEET[key] = self.project_information['检验批部位']
                    DIR_SHEET[key].font = self.Fontstyle
                    DIR_SHEET[key2] = '符合要求'
                    DIR_SHEET[key3] = '合格'
                else:

                    DIR_SHEET[key] = '/'
                    DIR_SHEET[key2] = '/'
                    DIR_SHEET[key3] = '/'

            if key == 'L10':
                if judge_part(
                        items=[
                            'HRB500',
                        ],
                        part=self.project_information['钢筋的强度']):

                    DIR_SHEET[key] = self.project_information['检验批部位']
                    DIR_SHEET[key].font = self.Fontstyle
                    DIR_SHEET[key2] = '符合要求'
                    DIR_SHEET[key3] = '合格'
                else:

                    DIR_SHEET[key] = '/'
                    DIR_SHEET[key2] = '/'
                    DIR_SHEET[key3] = '/'

            if key == 'L11':
                if judge_part(
                        items=[
                            'HRB'
                        ],
                        part=self.project_information['钢筋的强度']):

                    DIR_SHEET[key] = self.project_information['检验批部位']
                    DIR_SHEET[key].font = self.Fontstyle
                    DIR_SHEET[key2] = '符合要求'
                    DIR_SHEET[key3] = '合格'
                else:

                    DIR_SHEET[key] = '/'
                    DIR_SHEET[key2] = '/'
                    DIR_SHEET[key3] = '/'

            if key == 'L12':
                if judge_part(
                        items=[
                            'HPB'
                        ],
                        part=self.project_information['钢筋的强度']):

                    DIR_SHEET[key] = self.project_information['检验批部位']
                    DIR_SHEET[key].font = self.Fontstyle
                    DIR_SHEET[key2] = '符合要求'
                    DIR_SHEET[key3] = '合格'
                else:

                    DIR_SHEET[key] = '/'
                    DIR_SHEET[key2] = '/'
                    DIR_SHEET[key3] = '/'

            if key == 'L13':
                DIR_SHEET[key] = self.project_information['检验批部位']
                DIR_SHEET[key].font = self.Fontstyle
                DIR_SHEET[
                    key2] = f"检查{self.project_information['钢筋加工检查数量']}处，合格{self.project_information['钢筋加工检查数量']},符合设计与规范要求"
                DIR_SHEET[key3] = '合格'

            if key == 'L14':
                DIR_SHEET[key] = self.project_information['检验批部位']
                DIR_SHEET[key].font = self.Fontstyle
                DIR_Range = [-10, 10]
                self.To_sheet(key, DIR_SHEET, DIR_Range)
                DIR_SHEET[key3] = '合格'

            if key == 'L15':
                DIR_SHEET[key] = self.project_information['检验批部位']
                DIR_SHEET[key].font = self.Fontstyle
                DIR_Range = [-20, 20]
                self.To_sheet(key, DIR_SHEET, DIR_Range)
                DIR_SHEET[key3] = '合格'

            if key == 'L16':
                DIR_SHEET[key] = self.project_information['检验批部位']
                DIR_SHEET[key].font = self.Fontstyle
                DIR_Range = [-5, 5]
                self.To_sheet(key, DIR_SHEET, DIR_Range)
                DIR_SHEET[key3] = '合格'


# 混凝土的拌合物


class ConMix(object):

    def __init__(self, project_information, new_path_) -> None:

        dir_path = TEMPLATES['混凝土']['混凝土拌合物']

        self.DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

        self.project_information = project_information

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=10)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=8)

        self.new_path_ = new_path_

        self.FROM1()

        self.DirWorkBooK.save(self.new_path_)

        pass

    # 部位判别器
    @staticmethod
    def judge_part(items, part):
        pattern = '|'.join(str(x) for x in items)
        if len(re.findall(pattern, part)) > 0:
            return True
        else:
            return False

    # 写入数据所在行

    def To_sheet(self, key, sheet, Range):

        if self.project_information['混凝土的检查数量'] >= 10:

            for col in range(16, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])
                # print(sheet.cell(row=row,column=col).value)
        if self.project_information['混凝土的检查数量'] < 10:

            max_range = 26 - 10 + self.project_information['混凝土的检查数量']

            for col in range(16, max_range):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])

    # ***********************钢筋*******************************#
    # *********************钢筋安装(主表)******************************#

    def FROM1(self):

        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        # ****表头数据可以共用#

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['P5'] = self.project_information['分部工程']
        DIR_SHEET['F6'] = self.project_information['施工单位']
        DIR_SHEET['P6'] = self.project_information['项目负责人']
        DIR_SHEET['X6'] = self.project_information['混凝土的检验批容量']
        DIR_SHEET['F7'] = self.project_information['分包单位']
        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']
        DIR_SHEET['X7'] = self.project_information['检验批部位']
        DIR_SHEET['X7'].font = self.Fontstyle
        DIR_SHEET['X5'] = self.project_information['分项工程']
        DIR_SHEET['W28'] = self.project_information['表格时间']
        DIR_SHEET['U3'] = self.project_information['最终的检验批编号']

        # ****表头数据可以共用#

        # 模板
        ITEM_NYMBER = ['P{}'.format(x) for x in range(50)]

        for key1 in ITEM_NYMBER:

            key2 = key1.replace('P', 'R')
            key3 = key1.replace('P', 'S')
            key4 = key1.replace('P', 'Z')

            if key1 == 'P11':
                DIR_SHEET[key1] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key2] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P13':
                DIR_SHEET[key1] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key2] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P15':
                DIR_SHEET[key1] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key2] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P17':
                DIR_SHEET[key1] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key2] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P19':
                DIR_SHEET[key1] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key2] = self.project_information['混凝土的检查数量']
                DIR_SHEET[key3] = self.project_information['检查记录']
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P21':
                if self.project_information['抗冻性']:

                    DIR_SHEET[key1] = self.project_information['混凝土的检查数量']
                    DIR_SHEET[key2] = self.project_information['混凝土的检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"
                else:

                    DIR_SHEET[key1] = ''
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "/"

            if key1 == 'P23':
                if self.project_information['耐久性']:

                    DIR_SHEET[key1] = self.project_information['混凝土的检查数量']
                    DIR_SHEET[key2] = self.project_information['混凝土的检查数量']
                    DIR_SHEET[key3] = self.project_information['检查记录']
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"
                else:

                    DIR_SHEET[key1] = ''
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "/"


# 混凝土的施工


class ConWork(object):

    def __init__(self, project_information, new_path_) -> None:

        dir_path = TEMPLATES['混凝土']['混凝土施工']

        self.project_information = project_information

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=10)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=8)

        self.DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

        self.FROM()

        self.DirWorkBooK.save(new_path_)
        pass

    # 部位判别器

    # 写入数据所在行

    def To_sheet(self, key, sheet, Range):

        if self.project_information['混凝土的检查数量'] >= 10:

            for col in range(16, 26):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])
                # print(sheet.cell(row=row,column=col).value)
        if self.project_information['混凝土的检查数量'] < 10:

            max_range = 26 - 10 + self.project_information['混凝土的检查数量']

            for col in range(16, max_range):
                sheet.cell(
                    row=int(key[1:]), column=col).value = random.randint(
                    Range[0], Range[1])

    # ***********************钢筋*******************************#
    # *********************钢筋安装(主表)******************************#

    def FROM(self):
        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        # ****表头数据可以共用#

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['P5'] = self.project_information['分部工程']
        DIR_SHEET['F6'] = self.project_information['施工单位']
        DIR_SHEET['P6'] = self.project_information['项目负责人']
        DIR_SHEET['X6'] = self.project_information['混凝土的检验批容量']
        DIR_SHEET['F7'] = self.project_information['分包单位']
        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']
        DIR_SHEET['X7'] = self.project_information['检验批部位']
        DIR_SHEET['X7'].font = self.Fontstyle
        DIR_SHEET['X5'] = self.project_information['分项工程']
        DIR_SHEET['W23'] = self.project_information['表格时间']
        DIR_SHEET['U3'] = self.project_information['最终的检验批编号']

        # ****表头数据可以共用#

        # 模板
        ITEM_NYMBER = ['P{}'.format(x) for x in range(50)]

        for key1 in ITEM_NYMBER:
            key2 = key1.replace('P', 'R')
            key3 = key1.replace('P', 'S')
            key4 = key1.replace('P', 'Z')

            if key1 == 'P11':
                DIR_SHEET[key1] = '全'
                DIR_SHEET[key2] = ''
                DIR_SHEET[key3] = '该部位混凝土强度{},符合设计及规范要求'.format(
                    self.project_information['混凝土强度'])
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"

            if key1 == 'P14':
                if judge_part(
                        ['地下室'], self.project_information['检验批部位']) \
                        and judge_part(['顶板'], self.project_information['检验批部位']):

                    DIR_SHEET[key1] = '全'
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '后浇带位置留置合理,符合设计及规范要求.'
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "合格"

                else:
                    DIR_SHEET[key1] = ''
                    DIR_SHEET[key2] = ''
                    DIR_SHEET[key3] = '/'
                    DIR_SHEET[key3].font = self.Fontstyle
                    DIR_SHEET[key4] = "/"

            if key1 == 'P17':
                DIR_SHEET[key1] = '全'
                DIR_SHEET[key2] = ''
                DIR_SHEET[key3] = '混凝土浇筑养护时间符合规范要求，养护采用洒水养护'
                DIR_SHEET[key3].font = self.Fontstyle
                DIR_SHEET[key4] = "合格"


# 隐蔽验收(钢筋)


class RebarCheck(object):

    def __init__(self, project_information, _new_path_) -> None:

        self.sheet = None
        self.project_information = project_information

        dir_path = TEMPLATES['隐蔽验收']['钢筋隐蔽验收']

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=12)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=10)

        self.DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

        self.FORM()
        path = os.path.join(
            urls.TEMPLATES['隐蔽验收']['钢筋隐蔽验收图片'],
            project_information['隐蔽验收图片的名称'])

        try:
            self.save_to_excel(path)
        except BaseException:
            print(path)
        self.DirWorkBooK.save(_new_path_)

        self.DirWorkBooK.close()

    @staticmethod
    def offset_img(img):
        """精确设置图片位置，偏移量以万为单位进行微调吧，具体计算公式太麻烦了
        row column 的索引都是从0开始的,我这里要把图片插入到单元格B10
        """
        p2e = pixels_to_EMU
        h, w = img.height, img.width
        size = XDRPositiveSize2D(p2e(w), p2e(h))
        marker = AnchorMarker(col=13, colOff=10000, row=8, rowOff=20000)
        img.anchor = OneCellAnchor(_from=marker, ext=size)

    def save_to_excel(self, fig):
        """把图片插入到excel文件中的指定位置
        插入到指定单元格然后向右偏移一点距离，目的是不让图片的边框和单元格的边框重合
        :param fig: 图片
        :return:
        """
        # 获取模板 excel 的操作对象
        # 根据 Sheet1 这个名字来获取 Sheet1
        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]
        img = Image(fig)
        # 设置图片的宽和高
        cnt = 81
        img.width, img.height = (5 * cnt, 3 * cnt)
        self.offset_img(img)
        # 将图片添加到excel中
        DIR_SHEET.add_image(img)

    def FORM(self):

        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]
        DIR_SHEET['D4'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"
        DIR_SHEET['N4'] = self.project_information['分部工程']
        DIR_SHEET['R4'] = self.project_information['项目负责人']
        DIR_SHEET['D5'] = self.project_information['施工单位']
        DIR_SHEET['N5'] = self.project_information['检验批部位']
        DIR_SHEET['N5'].font = self.Fontstyle
        DIR_SHEET['N6'] = self.project_information['分项工程']
        DIR_SHEET['C21'] = self.project_information['表格时间']
        DIR_SHEET['S6'] = self.project_information['表格时间']
        DIR_SHEET['R5'] = self.project_information['施工图号']
        DIR_SHEET['R3'] = self.project_information['最终的检验批编号']
        DIR_SHEET['H8'] = '符合要求'
        DIR_SHEET['H9'] = '符合要求'
        DIR_SHEET['H10'] = '符合要求'
        if self.project_information['预埋件']:
            DIR_SHEET['H11'] = '符合要求'
        else:
            DIR_SHEET['H11'] = '/'

        DIR_SHEET['H12'] = '符合要求'
        DIR_SHEET['H13'] = '/'

        DIR_SHEET['N8'] = '钢筋的规格、数量、型号、尺寸、锚固长度等符合设计要求及规范规定'

        # =


# 技术复核


class TechnicalReview(object):

    def __init__(self, project_information, new_path__):
        self.project_information = project_information

        self.new_path__ = new_path__

        dir_path = TEMPLATES['技术复核']['技术复核']

        if len(project_information['检验批部位']) >= 10:
            self.Fontstyle = Font(size=6)
        if len(project_information['检验批部位']) < 10:
            self.Fontstyle = Font(size=8)

        self.DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

        self.FORM()

        self.DirWorkBooK.save(new_path__)

        self.DirWorkBooK.close()

    def Recode(self):

        result1 = '、'.join(
            [str(x) for x in self.project_information['技术复核数据']])  # 这边有好多

        result2 = '、'.join([str(random.randint(-5, 4))
                            for x in range(self.project_information['技术复核数量'])])
        result3 = '、'.join([str(random.randint(-5, 5))
                            for x in range(self.project_information['技术复核数量'])])

        recode = '模板的轴线尺寸允许偏差为:5mm;\n    实测为：{}mm'.format(result1) + '\n' \
                 + '模板的截面尺寸允许偏差为：+4,-5mm;\n    实测为：{}mm'.format(result2) + '\n' \
                 + '模板的标高允许偏差为:±5mm;\n    实测为：{}mm \n均符合要求 '.format(result3)

        return recode

    def FORM(self):
        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        DIR_SHEET['C3'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['D5'] = self.project_information['检验批部位']

        DIR_SHEET['G5'] = self.project_information['表格时间']

        DIR_SHEET['G3'] = self.project_information['施工单位']

        DIR_SHEET['J24'] = self.project_information['表格时间']

        DIR_SHEET['H5'] = self.Recode()


# 隐蔽验收（混凝土）


class ConCheck(object):
    def __init__(self, project_information, _new_path_) -> None:

        self.sheet = None
        self.project_information = project_information

        dir_path = TEMPLATES['隐蔽验收']['混凝土隐蔽验收']

        if len(project_information['检验批部位']) >= 12:
            self.Fontstyle = Font(size=10)
        if len(project_information['检验批部位']) < 12:
            self.Fontstyle = Font(size=8)
        self.DirWorkBooK = openpyxl.load_workbook(dir_path, data_only=True)

        self.FORM()

        self.DirWorkBooK.save(_new_path_)

        self.DirWorkBooK.close()

    def FORM(self):

        DIR_SHEET = self.DirWorkBooK[self.DirWorkBooK.sheetnames[0]]

        try:
            path = os.path.join(urls.TEMPLATES['隐蔽验收']['钢筋隐蔽验收图片'],
                                self.project_information['隐蔽验收图片的名称'])  # 留下来作为后续的一个接口

            DIR_SHEET.merge_cells(
                start_row=8,
                start_column=14,
                end_column=23,
                end_row=10)

        except BaseException:
            DIR_SHEET.merge_cells(
                start_row=8,
                start_column=14,
                end_column=23,
                end_row=21)

        DIR_SHEET['D4'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        if self.project_information['分部工程']:

            DIR_SHEET['N4'] = self.project_information['分部工程']
        else:
            print('分部工程为空')
            DIR_SHEET['N4'] = ''
            pass
        if self.project_information['项目负责人']:
            DIR_SHEET['R4'] = self.project_information['项目负责人']

        else:
            print('项目负责人为空')
        if self.project_information['施工单位']:

            DIR_SHEET['D5'] = self.project_information['施工单位']
        else:
            print('施工单位为空')
        DIR_SHEET['N5'] = self.project_information['检验批部位']
        DIR_SHEET['N5'].font = self.Fontstyle
        DIR_SHEET['N6'] = self.project_information['分项工程']
        DIR_SHEET['C21'] = self.project_information['表格时间']
        DIR_SHEET['S6'] = self.project_information['表格时间']
        DIR_SHEET['N8'] = self.project_information['检查记录']
        DIR_SHEET['R3'] = self.project_information['最终的检验批编号']
        try:

            DIR_SHEET['R5'] = self.project_information['施工图号']
        except BaseException:
            DIR_SHEET['R5'] = ''
            print('施工图号为空')


class Ground(object):

    def __init__(self, project_information, _new_path_) -> None:
        self.sheet = None
        self.project_information = project_information
        dir_path = TEMPLATES['建筑装饰装修']['地面']
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        self.From1()

        self.DirWorkBook.save(_new_path_)

        self.DirWorkBook.close()

    def From1(self):

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['E7'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['W7'] = self.project_information['项目负责人']

        DIR_SHEET['E8'] = self.project_information['施工单位']

        DIR_SHEET['M8'] = self.project_information['检验批部位']

        DIR_SHEET['W9'] = self.project_information['施工员']

        DIR_SHEET['W11'] = self.project_information['混凝土施工班组长']

        DIR_SHEET['E11'] = self.project_information['分包单位']

        DIR_SHEET['M11'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['H14'] = '粗骨料粒径5-31.5mm,未大于面层厚度的2/3,符合设计及规范要求'
        DIR_SHEET['R14'] = '同意施工单位自检结果,符合设计及规范要求'

        DIR_SHEET['H15'] = '防水水泥混凝土中掺入的外加剂的技术性能符合国家现有有关标准的规定'
        DIR_SHEET['R15'] = '同意施工单位自检结果,符合设计及规范要求'

        DIR_SHEET['H16'] = f"该面层的强度等级{self.project_information['混凝土强度']}符合设计要求."
        DIR_SHEET['R16'] = '同意施工单位自检结果,符合设计及规范要求'

        DIR_SHEET['H17'] = "面层与下一层结合牢固、且应无空鼓和开裂。"
        DIR_SHEET['R17'] = '同意施工单位自检结果,符合设计及规范要求'

        DIR_SHEET['H18'] = "面层表面无缺陷."
        DIR_SHEET['R18'] = '同意施工单位自检结果,符合设计及规范要求'

        DIR_SHEET['H19'] = "面层坡度符符合设计要求"
        DIR_SHEET['R19'] = '同意施工单位自检结果,符合设计及规范要求'

        DIR_SHEET['S30'] = self.project_information['表格时间']

        # 需要判断一些是否是室内还是室外

        for x in range(8, 28):
            DIR_SHEET.cell(row=22, column=x, value=random.randint(0, 5))

        for x in range(8, 28):
            DIR_SHEET.cell(row=24, column=x, value=random.randint(0, 3))

        if self.project_information['地面类型']:

            DIR_SHEET['H20'] = "踢脚线与柱、墙面紧密结合，踢脚线高度和出柱、墙厚度应符合设计要求且均匀一致 "
            DIR_SHEET['R20'] = '同意施工单位自检结果,符合设计及规范要求'

            for x in range(8, 28):
                DIR_SHEET.cell(row=23, column=x, value=random.randint(0, 4))

        else:

            DIR_SHEET['H20'] = "/"
            DIR_SHEET['R20'] = "/"


class RoofWaterProofing(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑屋面']['防水卷材']) -> None:
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑屋面'
        self.project_information['子分部工程'] = '卷材防水屋面'
        self.project_information['分项工程'] = '卷材防水层'
        self.inport_sheetname = inport_sheetname
        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        self.dir_path = dir_path

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def From1(self):
        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F6'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['AB6'] = self.project_information['项目负责人']

        DIR_SHEET['F7'] = self.project_information['施工单位']

        DIR_SHEET['R7'] = self.project_information['检验批部位']

        DIR_SHEET['AB7'] = str(self.project_information['施工面积']) + '㎡'

        DIR_SHEET['AB8'] = self.project_information['施工员']

        DIR_SHEET['F10'] = self.project_information['分包单位']

        DIR_SHEET['R10'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['W4'] = self.project_information['检验批编号']

        DIR_SHEET['X26'] = str_date(self.project_information['时间'])

        # 正式的内容
        DIR_SHEET[
            'M13'] = f"屋面采用{self.project_information['厂家名称']}\
            生产的{self.project_information['规格/型号']}的\
            {self.project_information['材料名称']};"
        DIR_SHEET[
            'M13'].alignment = Alignment(wrap_text=True, vertical='center', horizontal='center')
        DIR_SHEET['M13'].font = Font(size=8)
        DIR_SHEET['W13'] = '相关材料已经过进场验收合格，同意施工单位自检结果'
        DIR_SHEET['W13'].font = Font(size=8)

        DIR_SHEET['M14'] = '卷材防水层无渗漏和积水现象'
        DIR_SHEET['W14'] = '相关部位已经过组织验收，符合设计及规范要求'
        DIR_SHEET['W14'].font = Font(size=8)

        DIR_SHEET['M15'] = '卷材防水层防水构造要求符合设计及规范要求'
        DIR_SHEET['M15'].alignment = Alignment(
            wrap_text=True, vertical='center', horizontal='center')
        DIR_SHEET['M15'].font = Font(size=8)
        DIR_SHEET['W15'] = '相关部位已经过组织验收,符合设计及规范要求'
        DIR_SHEET['W15'].font = Font(size=8)

        DIR_SHEET['M17'] = '卷材的搭接缝及密封质量要求'
        DIR_SHEET['M17'].alignment = Alignment(
            wrap_text=True, vertical='center', horizontal='center')
        DIR_SHEET['M17'].font = Font(size=8)
        DIR_SHEET['W17'] = '相关部位已经过组织验收符合要求，符合设计及规范要求。'
        DIR_SHEET['W17'].font = Font(size=8)

        DIR_SHEET['M18'] = '卷材防水层的收头与基层粘结，钉压牢固，密封严密.'
        DIR_SHEET['M18'].alignment = Alignment(
            wrap_text=True, vertical='center', horizontal='center')
        DIR_SHEET['M18'].font = Font(size=8)

        DIR_SHEET['W18'] = '相关部位已经过组织验收符合要求，符合设计及规范要求。'
        DIR_SHEET['M18'].alignment = Alignment(
            wrap_text=True, vertical='center', horizontal='center')
        DIR_SHEET['W18'].font = Font(size=8)

        for x in range(13, 32):
            DIR_SHEET.cell(row=19, column=x, value=random.randint(10, 20))
            DIR_SHEET.cell(row=19, column=x).font = Font(size=8)

        DIR_SHEET['M20'] = '屋面排汽构造的排汽道符合质量要求.'
        DIR_SHEET['W20'] = '相关部位已经过组织验收符合要求，同意施工单位自检结果。'
        DIR_SHEET['W20'].font = Font(size=8)

        DIR_SHEET['M21'] = '施工操作依据符合要求'
        DIR_SHEET['M21'].font = Font(size=8)

        DIR_SHEET['W21'] = '同意施工单位自检结果'
        DIR_SHEET['W21'].font = Font(size=8)

        DIR_SHEET['M22'] = '质量验收检查记录齐全完整'
        DIR_SHEET['M22'].font = Font(size=8)

        DIR_SHEET['W22'] = '同意施工单位自检结果'
        DIR_SHEET['W22'].font = Font(size=8)


class HeatPreserveRation(object):
    """
    :保温层
    """

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑屋面']['保温层']) -> None:
        self.project_information = project_information

        self.project_information['分部工程'] = '建筑屋面'

        self.project_information['子分部工程'] = '卷材防水屋面'

        self.project_information['分项工程'] = '保温层'

        self.inport_sheetname = inport_sheetname

        self.dir_path = dir_path
        print(f"{project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def From1(self):

        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F7'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['AB7'] = self.project_information['项目负责人']

        DIR_SHEET['F8'] = self.project_information['施工单位']

        DIR_SHEET['R8'] = self.project_information['检验批部位']

        DIR_SHEET['AB9'] = self.project_information['施工员']

        DIR_SHEET['F11'] = self.project_information['分包单位']

        DIR_SHEET['R11'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['V5'] = f"编号：{self.project_information['检验批编号']}"
        # 正式的内容

        Fontstyle1 = Font(size=8)
        DIR_SHEET[
            'M14'] = f"屋面采用{self.project_information['厂家名称']}生产的{self.project_information['规格/型号']}的{self.project_information['材料名称']};"

        DIR_SHEET['M14'].font = Fontstyle1

        DIR_SHEET['W14'] = '相关材料已经过进场验收合格，同意施工单位自检结果'

        DIR_SHEET['M15'] = '卷材防水层无渗漏和积水现象'
        DIR_SHEET['W15'] = '相关部位已经过组织验收，符合设计及规范要求'

        DIR_SHEET['M16'] = '卷材防水层防水构造要求符合设计及规范要求'
        DIR_SHEET['W16'] = '相关部位已经过组织验收,符合设计及规范要求'

        DIR_SHEET['M20'] = '板状保温材料铺设及符合设计要求及规范要求。'
        DIR_SHEET['W20'] = '相关部位已经过组织验收符合要求，符合设计及规范要求。'

        DIR_SHEET['M21'] = '固定件规格、数量、位置要求，垫片应保温层表面齐平，符合要求'
        DIR_SHEET['M21'].font = Fontstyle1
        DIR_SHEET['W21'] = '相关部位已经过组织验收符合要求，同意施工单位自检结果。'

        for x in range(13, 33):
            DIR_SHEET.cell(
                row=22, column=x, value=random.randint(
                    0, 5)).font = Fontstyle1

        for x in range(13, 33):
            Fontstyle2 = Font(size=6)
            value = random.randint(0, 20) / 10
            DIR_SHEET.cell(row=23, column=x, value=value).font = Fontstyle2

        DIR_SHEET['M25'] = '记录完整且详实'
        DIR_SHEET['W25'] = '相关记录已查看,符合实际情况要求'
        DIR_SHEET['W25'].font = Fontstyle1

        DIR_SHEET['M26'] = '记录完整且详实'
        DIR_SHEET['W26'] = '相关记录已查看,符合实际情况要求'
        DIR_SHEET['W26'].font = Fontstyle1


class SupplyWaterCold(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑给排水']['室内给排水管道安装']) -> None:
        # 读入基础的参数
        self.FontStyle = None
        self.project_information = project_information

        self.project_information['分部工程'] = '建筑给排水及供暖'

        self.project_information['子分部工程'] = '室内给水系统'

        self.project_information['分项工程'] = '给水管道及配件安装'

        self.inport_sheetname = inport_sheetname
        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        self.dir_path = dir_path

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        # from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def To_sheet(self, key, sheet, Range, number, start_number):

        for x in range(number):
            sheet.cell(row=key, column=start_number +
                       x).value = random.randint(Range[0] * 10, Range[1] * 10) / 10
            sheet.cell(row=key, column=start_number +
                       x).font = self.FontStyle

    def To_sheet2(self, key, sheet, Range, number, start_number):

        for x in range(number):
            sheet.cell(row=key, column=start_number +
                       x).value = random.randint(Range[0], Range[1])

            sheet.cell(row=key, column=start_number +
                       x).font = self.FontStyle1

    def To_sheet3(self, key, sheet, Range, number, start_number):

        for x in range(number):
            sheet.cell(row=key, column=start_number +
                       x).value = random.randint(Range[0] * 100, Range[1] * 100) / 100

            sheet.cell(row=key, column=start_number +
                       x).font = self.FontStyle

    def From1(self):

        # 字体
        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=7)

        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G9'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['P10'] = self.project_information['项目负责人']

        DIR_SHEET['G10'] = self.project_information['施工单位']

        DIR_SHEET['Z11'] = self.project_information['检验批部位']

        DIR_SHEET['G11'] = self.project_information['分包单位']

        DIR_SHEET['P11'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['Z10'] = str(self.project_information['管道长度']) + 'm'

        DIR_SHEET['S3'] = f"编号：{self.project_information['检验批编号']}"

        DIR_SHEET['U42'] = str_date(self.project_information['时间'])

        for key in range(14, 39):

            if key == 14:
                # 正式的内容
                # 1、给水管道水压试验
                DIR_SHEET['N14'] = '全'
                DIR_SHEET.cell(row=key, column=17).value = '试验合格,符合设计及规范要求'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 15:
                # 2、给水系统通水试验
                DIR_SHEET.cell(row=key, column=14).value = 10
                DIR_SHEET.cell(row=key, column=17).value = '试验合格,符合设计及规范要求'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 16:
                # 3、生活给水系统管道冲洗和消毒
                DIR_SHEET.cell(row=key, column=14).value = 10
                DIR_SHEET.cell(
                    row=key, column=17).value = '已按照要求对生活给水系统管道冲洗和消毒'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 17:
                # 4、直埋金属给水管道防腐

                if self.project_information['是否有直埋金属管道']:
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(row=key, column=17).value = '已按照要求对给水管道进行防腐'
                    DIR_SHEET.cell(row=key, column=27).value = '合格'
                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 18:
                # 一般项目
                # 1、给排水管铺设的平行、垂直净距

                DIR_SHEET.cell(row=key, column=14).value = '全'
                DIR_SHEET.cell(
                    row=key, column=16).value = random.randint(3, 10)
                DIR_SHEET.cell(
                    row=key, column=17).value = '给排水管铺设的平行、垂直净距符合规范及设计要求'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 19:
                # 2、金属给水管道及管件焊接

                if self.project_information['管道类型'] == '金属':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    DIR_SHEET.cell(
                        row=key, column=17).value = f"检查{DIR_SHEET['P19']}处，合格{DIR_SHEET['P19']}处，符合规范要求"
                    DIR_SHEET.cell(row=key, column=27).value = '合格'
                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 20:
                # 3、给水水平管道坡度坡向
                DIR_SHEET.cell(row=key, column=14).value = '全'
                _number = random.randint(3, 10)
                DIR_SHEET.cell(row=key, column=16).value = _number
                DIR_SHEET.cell(
                    row=key, column=17).value = f"检查{_number}处,合格{_number}处,符合规范要求"
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 21:

                # 4、管道支、吊架
                if self.project_information['管道支、吊架']:
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    _number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = _number
                    DIR_SHEET.cell(
                        row=key, column=17).value = f"检查{_number}处,合格{_number}处,符合规范要求"
                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 22:

                # 5、水表安装
                if self.project_information['水表数量']:
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    DIR_SHEET.cell(
                        row=key,
                        column=17).value = f"检查{self.project_information['水表数量']}处，" \
                                           f"合格{self.project_information['水表数量']}处，符合设计要求"
                    DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 23:

                # 6、水平管道纵、横方向弯曲允许偏差
                if self.project_information['管道类型'] == '钢管':

                    _number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=14).value = _number
                    DIR_SHEET.cell(row=key, column=16).value = _number
                    self.To_sheet(key, DIR_SHEET, [
                        0, 1], _number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格 "

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 24:

                if self.project_information['管道类型'] == '钢管':

                    if self.project_information['管道长度'] > 25:
                        _number = random.randint(3, 10)
                        DIR_SHEET.cell(row=key, column=14).value = _number
                        DIR_SHEET.cell(row=key, column=16).value = _number
                        self.To_sheet2(key, DIR_SHEET, [
                            0, 25], number=_number, start_number=17)
                        DIR_SHEET.cell(row=key, column=27).value = "合格"
                    else:
                        DIR_SHEET.merge_cells(
                            start_row=key, start_column=17, end_row=key, end_column=25)
                        DIR_SHEET.cell(row=key, column=17).value = "/"
                        DIR_SHEET.cell(row=key, column=27).value = "/"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 25:

                if self.project_information['管道类型'] == '塑料管、复合管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    self.To_sheet(key, DIR_SHEET, [0, 1.5], DIR_SHEET.cell(
                        row=key, column=16).value, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 26:

                if self.project_information['管道类型'] == '塑料管、复合管':

                    if self.project_information['管道长度'] > 25:
                        DIR_SHEET.cell(row=key, column=14).value = '全'
                        _number = random.randint(3, 10)
                        DIR_SHEET.cell(row=key, column=16).value = _number
                        self.To_sheet2(
                            key, DIR_SHEET, [
                                0, 25], number=_number, start_number=17)
                        DIR_SHEET.cell(row=key, column=27).value = "合格"

                    else:
                        DIR_SHEET.merge_cells(
                            start_row=key, start_column=17, end_row=key, end_column=25)
                        DIR_SHEET.cell(row=key, column=17).value = "/"
                        DIR_SHEET.cell(row=key, column=27).value = "/"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 27:

                if self.project_information['管道类型'] == '铸铁管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    self.To_sheet(key, DIR_SHEET, [0, 2], DIR_SHEET.cell(
                        row=key, column=16).value, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 28:

                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['管道长度'] > 25:
                        DIR_SHEET.cell(row=key, column=14).value = '全'
                        _number = random.randint(3, 10)
                        DIR_SHEET.cell(row=key, column=16).value = _number
                        self.To_sheet2(
                            key, DIR_SHEET, [
                                0, 25], number=_number, start_number=17)
                        DIR_SHEET.cell(row=key, column=27).value = "合格"
                    else:
                        DIR_SHEET.merge_cells(
                            start_row=key, start_column=17, end_row=key, end_column=25)
                        DIR_SHEET.cell(row=key, column=17).value = "/"
                        DIR_SHEET.cell(row=key, column=27).value = "/"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            # 立管立管垂直度允许偏差

            if key == 29:

                if self.project_information['管道类型'] == '钢管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    _number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = _number
                    self.To_sheet(key, DIR_SHEET, [
                        0, 3], _number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 30:

                if self.project_information['管道类型'] == '钢管':
                    if self.project_information['管道长度'] > 5:
                        DIR_SHEET.cell(row=key, column=14).value = '全'
                        _number = random.randint(3, 10)
                        DIR_SHEET.cell(row=key, column=16).value = _number
                        self.To_sheet2(key, DIR_SHEET, [
                            0, 8], number=_number, start_number=17)
                        DIR_SHEET.cell(row=key, column=27).value = "合格"
                    else:
                        DIR_SHEET.merge_cells(
                            start_row=key, start_column=17, end_row=key, end_column=25)
                        DIR_SHEET.cell(row=key, column=17).value = "/"
                        DIR_SHEET.cell(row=key, column=27).value = "/"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 31:

                if self.project_information['管道类型'] == '塑料管、复合管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    self.To_sheet(key, DIR_SHEET, [0, 2], DIR_SHEET.cell(
                        row=key, column=16).value, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 32:

                if self.project_information['管道类型'] == '塑料管、复合管':
                    if self.project_information['管道长度'] > 25:
                        DIR_SHEET.cell(row=key, column=14).value = '全'
                        _number = random.randint(3, 10)
                        DIR_SHEET.cell(row=key, column=16).value = _number
                        self.To_sheet2(
                            key, DIR_SHEET, [
                                0, 8], number=_number, start_number=17)
                        DIR_SHEET.cell(row=key, column=27).value = "合格"
                    else:
                        DIR_SHEET.merge_cells(
                            start_row=key, start_column=17, end_row=key, end_column=25)
                        DIR_SHEET.cell(row=key, column=17).value = "/"
                        DIR_SHEET.cell(row=key, column=27).value = "/"
                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 33:

                if self.project_information['管道类型'] == '铸铁管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    self.To_sheet(key, DIR_SHEET, [0, 3], DIR_SHEET.cell(
                        row=key, column=16).value, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 34:

                if self.project_information['管道类型'] == '铸铁管':
                    if self.project_information['管道长度'] > 5:
                        DIR_SHEET.cell(row=key, column=14).value = '全'
                        _number = random.randint(3, 10)
                        DIR_SHEET.cell(row=key, column=16).value = _number
                        self.To_sheet2(
                            key, DIR_SHEET, [
                                0, 10], number=_number, start_number=17)
                        DIR_SHEET.cell(row=key, column=27).value = "合格"
                    else:
                        DIR_SHEET.merge_cells(
                            start_row=key, start_column=17, end_row=key, end_column=25)
                        DIR_SHEET.cell(row=key, column=17).value = "/"
                        DIR_SHEET.cell(row=key, column=27).value = "/"
                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 35:

                if JudgeBool(self.project_information['是否存在成排管段/或阀门']):
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    _number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = _number
                    self.To_sheet(
                        key, DIR_SHEET, [
                            0, 3], number=_number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"
                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 36:

                if JudgeBool(self.project_information['是否存在保护层']):
                    # 管道及设备保温厚度
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    _number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = _number
                    self.To_sheet3(key, DIR_SHEET, [
                        -0.05, 0.1], number=_number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 37:

                if JudgeBool(self.project_information['是否存在保护层']):

                    if self.project_information['如果存在保护层，保护层的类型'] == '卷材':
                        # 管道及设备保温卷材
                        DIR_SHEET.cell(row=key, column=14).value = '全'
                        _number = random.randint(3, 10)
                        DIR_SHEET.cell(row=key, column=16).value = _number
                        self.To_sheet(
                            key, DIR_SHEET, [
                                0, 5], number=_number, start_number=17)
                        DIR_SHEET.cell(row=key, column=27).value = "合格"

                    else:
                        DIR_SHEET.merge_cells(
                            start_row=key, start_column=17, end_row=key, end_column=25)
                        DIR_SHEET.cell(row=key, column=17).value = "/"
                        DIR_SHEET.cell(row=key, column=27).value = "/"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 38:

                if JudgeBool(self.project_information['是否存在保护层']):

                    if self.project_information['如果存在保护层，保护层的类型'] == '涂料':
                        # 管道及设备涂抹

                        DIR_SHEET.cell(row=key, column=14).value = '全'
                        _number = random.randint(3, 10)
                        DIR_SHEET.cell(row=key, column=16).value = _number
                        self.To_sheet(
                            key, DIR_SHEET, [
                                0, 10], number=_number, start_number=17)
                        DIR_SHEET.cell(row=key, column=27).value = "合格"
                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, start_column=17, end_row=key, end_column=25)
                        DIR_SHEET.cell(row=key, column=17).value = "/"
                        DIR_SHEET.cell(row=key, column=27).value = "/"
                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=25)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"


# 室内给水管道安装（热水）


class SupplyWaterHot(object):



    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑给排水']['室内热水管道安装']) -> None:
        self.project_information = project_information

        self.project_information['分部工程'] = '建筑给排水及供暖'

        self.project_information['子分部工程'] = '室内热水供应系统'

        self.project_information['分项工程'] = '管道及配件安装'

        self.inport_sheetname = inport_sheetname
        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        self.dir_path = dir_path

        # 读取模 自作主张现板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def To_sheet(self, key, sheet, Range, number, start_number):

        for x in range(number):
            sheet.cell(row=key, column=start_number +
                       x).value = random.randint(1, Range[1] * 10) / 10
            sheet.cell(row=key, column=start_number +
                       x).font = Font(size=7)

    def To_sheet2(self, key, sheet, Range, number, start_number):

        for x in range(number):
            sheet.cell(row=key, column=start_number +
                       x).value = random.randint(Range[0] + 1, Range[1])

            sheet.cell(row=key, column=start_number +
                       x).font = Font(size=8)

    def To_sheet3(self, key, sheet, Range, number, start_number):

        for x in range(number):
            sheet.cell(row=key, column=start_number +
                       x).value = random.randint(Range[0] * 100 + 1, Range[1] * 100) / 100

            sheet.cell(row=key, column=start_number +
                       x).font = Font(size=8)

    def From1(self):

        # 表头



        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G10'] = self.project_information['项目名称']

        DIR_SHEET['P8'] = self.project_information['项目负责人']

        DIR_SHEET['G8'] = self.project_information['施工单位']

        DIR_SHEET['Y9'] = self.project_information['检验批部位']

        DIR_SHEET['G9'] = self.project_information['分包单位']

        DIR_SHEET['P9'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['Y8'] = str(self.project_information['管道长度']) + 'm'

        DIR_SHEET['U35'] = str_date(self.project_information['时间'])

        DIR_SHEET['V4'] = self.project_information['检验批编号']

        for key in range(12, 39):

            if key == 12:
                # 正式的内容
                # 热水供应系统管道水压试验
                DIR_SHEET.cell(row=key, column=14).value = 10
                DIR_SHEET.cell(row=key, column=17).value = '试验合格,符合设计及规范要求'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 13:
                # 水供应系统管道安装补偿器
                DIR_SHEET.cell(row=key, column=14).value = 10
                DIR_SHEET.cell(row=key, column=17).value = '试验合格,符合设计及规范要求'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 14:
                # 热水供应系统管道冲洗
                DIR_SHEET.cell(row=key, column=14).value = 10
                DIR_SHEET.cell(
                    row=key, column=17).value = '已按照要求对热水供应系统管道冲洗'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 15:
                # 管道安装坡度
                DIR_SHEET.cell(row=key, column=14).value = '全'
                DIR_SHEET.cell(row=key, column=17).value = '管道安装坡度符合设计要求'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 16:
                # 一般项目
                # 温度控制器和阀门安装

                DIR_SHEET.cell(row=key, column=14).value = '全'
                number = random.randint(3, 10)
                DIR_SHEET.cell(
                    row=key, column=16).value = number
                DIR_SHEET.cell(
                    row=key, column=17).value = f'检查{number}处,合格{number}处,符合设计要求'
                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 17:

                # 6、水平管道纵、横方向弯曲允许偏差
                if self.project_information['管道类型'] == '钢管':

                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=14).value = number
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet(key, DIR_SHEET, [
                        0, 1], number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格 "

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 18:

                if self.project_information['管道类型'] == '金属' and self.project_information[
                        '如果是金属管道，金属管道的类型'] == '钢管' and self.project_information['管道长度'] > 25:

                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=14).value = number
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet2(key, DIR_SHEET, [
                        0, 25], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 19:

                if self.project_information['管道类型'] == '塑料管、复合管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    self.To_sheet(key, DIR_SHEET, [0, 1.5], DIR_SHEET.cell(
                        row=key, column=16).value, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 20:

                if self.project_information['管道类型'] == '塑料管、复合管' and self.project_information[
                        '管道长度'] > 25:

                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet2(
                        key, DIR_SHEET, [
                            0, 25], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 21:

                if self.project_information['管道类型'] == '铸铁管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    self.To_sheet(key, DIR_SHEET, [0, 2], DIR_SHEET.cell(
                        row=key, column=16).value, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 22:

                if self.project_information['管道类型'] == '铸铁管' and self.project_information['管道长度'] > 25:

                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet2(
                        key, DIR_SHEET, [
                            0, 25], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            # 立管立管垂直度允许偏差

            if key == 23:

                if self.project_information['管道类型'] == '钢管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet(key, DIR_SHEET, [
                        0, 3], number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 24:

                if self.project_information['管道类型'] == '金属' and self.project_information[
                        '如果是金属管道，金属管道的类型'] == '钢管' and self.project_information['管道长度'] > 5:

                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet2(key, DIR_SHEET, [
                        0, 8], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 25:

                if self.project_information['管道类型'] == '塑料管、复合管':
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    self.To_sheet(key, DIR_SHEET, [0, 2], DIR_SHEET.cell(
                        row=key, column=16).value, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 26:

                if self.project_information['管道类型'] == '塑料管、复合管' and self.project_information[
                        '管道长度'] > 25:

                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet2(
                        key, DIR_SHEET, [
                            0, 8], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 27:

                if self.project_information['管道类型'] == '金属' and self.project_information[
                        '如果是金属管道，金属管道的类型'] == '铸铁管':

                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    DIR_SHEET.cell(
                        row=key, column=16).value = random.randint(3, 10)
                    self.To_sheet(key, DIR_SHEET, [0, 3], DIR_SHEET.cell(
                        row=key, column=16).value, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 28:

                if self.project_information['管道类型'] == '金属' and self.project_information[
                        '如果是金属管道，金属管道的类型'] == '铸铁管' and self.project_information['管道长度'] > 5:

                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet2(
                        key, DIR_SHEET, [
                            0, 10], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 29:

                if JudgeBool(self.project_information['是否存在保护层']):
                    # 管道及设备保温厚度
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet3(key, DIR_SHEET, [
                        -0.05, 0.1], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 30:

                if JudgeBool(self.project_information['是否存在保护层']) and \
                        self.project_information['如果存在保护层，保护层的类型'] == '卷材':

                    # 管道及设备保温卷材
                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet(
                        key, DIR_SHEET, [
                            0, 5], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"

            if key == 31:

                if JudgeBool(self.project_information['是否存在保护层']) \
                        and self.project_information['如果存在保护层，保护层的类型'] == '涂料':
                    # 管道及设备涂抹

                    DIR_SHEET.cell(row=key, column=14).value = '全'
                    number = random.randint(3, 10)
                    DIR_SHEET.cell(row=key, column=16).value = number
                    self.To_sheet(
                        key, DIR_SHEET, [
                            0, 10], number=number, start_number=17)
                    DIR_SHEET.cell(row=key, column=27).value = "合格"

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)
                    DIR_SHEET.cell(row=key, column=17).value = "/"
                    DIR_SHEET.cell(row=key, column=27).value = "/"


# 室外给水管道安装


class OutSupplyWaterCold(object):

    def __init__(self, project_information, _new_path_) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        self.project_information = project_information
        dir_path = TEMPLATES['建筑给排水']['室外给排水管道安装']
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        self.FontStyles()
        self.From1()

        self.DirWorkBook.save(_new_path_)

        self.DirWorkBook.close()

    def FontStyles(self):

        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=7)

    def To_sheet(self, start_row, sheet, Range, number, start_col):

        for x in range(number):
            sheet.cell(row=start_row, column=start_col +
                       x).value = random.randint(Range[0] * 10, Range[1] * 10) / 10
            sheet.cell(row=start_row, column=start_col +
                       x).font = self.FontStyle

    def To_sheet2(self, start_row, sheet, Range, number, start_col):

        for x in range(number):
            sheet.cell(row=start_row, column=start_col +
                       x).value = random.randint(Range[0], Range[1])

            sheet.cell(row=start_row, column=start_col +
                       x).font = self.FontStyle1

    def To_sheet3(self, start_row, sheet, Range, number, start_col):

        for x in range(number):
            sheet.cell(row=start_row, column=start_col +
                       x).value = random.randint(Range[0] * 100, Range[1] * 100) / 100

            sheet.cell(row=start_row, column=start_col +
                       x).font = self.FontStyle

    def From1(self):

        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F7'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['AB7'] = self.project_information['项目负责人']

        DIR_SHEET['F8'] = self.project_information['施工单位']

        DIR_SHEET['R8'] = self.project_information['检验批部位']

        DIR_SHEET['F11'] = self.project_information['分包单位']

        DIR_SHEET['R11'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['AB11'] = self.project_information['给排水管道施工组长']

        DIR_SHEET['Z10'] = str(self.project_information['管道长度']) + 'm'

        for key in range(13, 39):

            if key == 13:
                # 正式的内容
                # 1、管道埋地深度
                DIR_SHEET.cell(row=key, column=13).value = '管道埋地深度符合设计及规范要求'
                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果，符合要求'

            if key == 14:
                # 2、管道不得直接穿越污染源
                DIR_SHEET.cell(row=key, column=13).value = '管道无直接穿越污染源'
                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果，符合要求'

            if key == 15:
                # 3、管道接口、卡扣、卡箍的位置
                DIR_SHEET.cell(row=key, column=13).value = '管道接口、卡扣、卡箍的位置符合要求'
                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果，符合要求'

            if key == 16:
                # 4、法兰或承口在井室内的位置

                DIR_SHEET.cell(row=key, column=13).value = '法兰或承口在井室内的位置符合要求 '

                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果，符合要求'

            if key == 17:
                # 5、管网水压试验

                DIR_SHEET.cell(row=key, column=13).value = '管网水压试验结果符合要求'

                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果，符合要求'

            if key == 18:
                # 6、镀锌钢管防腐

                DIR_SHEET.cell(row=key, column=13).value = '镀锌钢管防腐符合设计规范要求'

                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果，符合要求'

            if key == 19:
                # 6、管道冲洗、消毒检验

                DIR_SHEET.cell(row=key, column=13).value = '管道冲洗、消毒检验符合设计规范要求'

                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果，符合要求'

            if key == 20:
                # 7、管道的坐标、标高、坡度

                DIR_SHEET.cell(
                    row=key, column=13).value = '管道的坐标、标高、坡度符合设计规范要求'

                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果，符合要求'

            if key == 22:

                # 6、水平管道纵、横方向弯曲允许偏差
                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['敷设方式'] == '埋地敷设':

                        Range = [0, 100]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=13)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 23:

                # 6、水平管道纵、横方向弯曲允许偏差
                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['敷设方式'] == '敷设在沟槽内' or self.project_information[
                            '敷设方式'] == '架空':

                        Range = [0, 50]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=13)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 24:

                if self.project_information['管道类型'] == '钢管' or self.project_information[
                        '管道类型'] == '塑料管复合管':

                    if self.project_information['敷设方式'] == '埋地敷设':

                        Range = [0, 100]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 25:
                if self.project_information['管道类型'] == '钢管' or self.project_information[
                        '管道类型'] == '塑料管复合管':

                    if self.project_information['敷设方式'] == '敷设在沟槽内' or self.project_information[
                            '敷设方式'] == '架空':

                        Range = [0, 100]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 26:

                # 6、水平管道纵、横方向弯曲允许偏差
                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['敷设方式'] == '埋地敷设':

                        Range = [-50, 50]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=13)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 27:

                # 6、水平管道纵、横方向弯曲允许偏差
                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['敷设方式'] == '敷设在沟槽内':

                        Range = [-30, 30]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=13)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 28:

                if self.project_information['管道类型'] == '钢管' or self.project_information[
                        '管道类型'] == '塑料管复合管':

                    if self.project_information['敷设方式'] == '埋地敷设':

                        Range = [-50, 50]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 29:

                if self.project_information['管道类型'] == '钢管' or self.project_information[
                        '管道类型'] == '塑料管复合管':

                    if self.project_information['敷设方式'] == '敷设在沟槽内' or self.project_information[
                            '敷设方式'] == '架空':

                        Range = [-30, 30]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')
            if key == 30:

                # 6、水平管道纵、横方向弯曲允许偏差
                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['直段(25m以上)起点-终点']:

                        Range = [0, 40]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=13)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 31:

                # 6、水平管道纵、横方向弯曲允许偏差
                if self.project_information['管道类型'] == '钢管' or self.project_information[
                        '管道类型'] == '塑料管复合管':

                    if self.project_information['直段(25m以上)起点-终点']:

                        Range = [0, 40]

                        number = random.randint(3, 10)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=13)

                        self.To_sheet2(
                            start_row=key,
                            sheet=DIR_SHEET,
                            Range=Range,
                            number=number,
                            start_col=23)

                    else:

                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=13, end_column=22)
                        DIR_SHEET.cell(row=13, column=22, value='/')
                        DIR_SHEET.merge_cells(
                            start_row=key, end_row=key, start_column=23, end_column=32)
                        DIR_SHEET.cell(row=23, column=22, value='/')

            if key == 32:

                # 管道和金属支架的涂漆

                if self.project_information['管道类型'] == '钢管' or self.project_information['敷设方式'] == '架空':
                    DIR_SHEET.cell(row=key, column=13, value='管道和金属支架的涂漆符合要求')
                    DIR_SHEET.cell(row=key, column=23, value='同意施工单位自检结果符合要求')

                else:
                    DIR_SHEET.cell(row=key, column=13, value='/')
                    DIR_SHEET.cell(row=key, column=23, value='/')

            if key == 33:
                DIR_SHEET.cell(row=key, column=13).value = '管道连接、阀门、水表等安装符合要求'

                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果,安装符合要求'

            if key == 34:
                DIR_SHEET.cell(row=key, column=13).value = '给水管与污水管的间距符合要求'

                DIR_SHEET.cell(row=key, column=23).value = '同意施工单位自检结果,安装符合要求'

            if key == 35:

                if self.project_information['管道类型'] == '铸铁管':

                    DIR_SHEET.cell(
                        row=key, column=13).value = '铸铁管承插捻口连接的对口间隙符合要求'

                    DIR_SHEET.cell(
                        row=key, column=23).value = '同意施工单位自检结果,安装符合要求'
                else:
                    DIR_SHEET.cell(row=key, column=13).value = '/'

                    DIR_SHEET.cell(row=key, column=23).value = '/'

            if key == 36:

                if self.project_information['管道类型'] == '铸铁管':

                    DIR_SHEET.cell(
                        row=key, column=13).value = '铸铁管承插捻口连接的对口间隙符合要求'

                    DIR_SHEET.cell(
                        row=key, column=23).value = '同意施工单位自检结果,安装符合要求'
                else:
                    DIR_SHEET.cell(row=key, column=13).value = '/'

                    DIR_SHEET.cell(row=key, column=23).value = '/'

            if key == 37:

                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['捻口材料'] == '油麻填料':

                        DIR_SHEET.cell(
                            row=key, column=13).value = '捻口用的油麻填料符合要求'

                        DIR_SHEET.cell(
                            row=key, column=23).value = '同意施工单位自检结果,安装符合要求'
                    else:
                        DIR_SHEET.cell(row=key, column=13).value = '/'

                        DIR_SHEET.cell(row=key, column=23).value = '/'

            if key == 38:

                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['捻口材料'] == '水泥':

                        DIR_SHEET.cell(
                            row=key, column=13).value = '捻口用水泥强度符合要求'

                        DIR_SHEET.cell(
                            row=key, column=23).value = '同意施工单位自检结果,安装符合要求'
                    else:
                        DIR_SHEET.cell(row=key, column=13).value = '/'

                        DIR_SHEET.cell(row=key, column=23).value = '/'

            if key == 39:

                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['捻口材料'] == '水泥':

                        DIR_SHEET.cell(
                            row=key, column=13).value = '水泥捻口的防腐  符合要求'

                        DIR_SHEET.cell(
                            row=key, column=23).value = '同意施工单位自检结果,安装符合要求'
                    else:
                        DIR_SHEET.cell(row=key, column=13).value = '/'

                        DIR_SHEET.cell(row=key, column=23).value = '/'

            if key == 39:

                if self.project_information['管道类型'] == '铸铁管':

                    if self.project_information['捻口材料'] == '水泥':

                        DIR_SHEET.cell(
                            row=key, column=13).value = '捻口用水泥强度大于32.5Mpa符合要求'

                        DIR_SHEET.cell(
                            row=key, column=23).value = '同意施工单位自检结果,安装符合要求'
                    else:
                        DIR_SHEET.cell(row=key, column=13).value = '/'

                        DIR_SHEET.cell(row=key, column=23).value = '/'

            if key == 40:

                if self.project_information['管道类型'] == '塑料管复合管':

                    DIR_SHEET.cell(
                        row=key, column=13).value = '橡胶圈接口密封与偏转角限值符合要求'

                    DIR_SHEET.cell(
                        row=key, column=23).value = '同意施工单位自检结果,安装符合要求'
                else:
                    DIR_SHEET.cell(row=key, column=13).value = '/'

                    DIR_SHEET.cell(row=key, column=23).value = '/'


# 市政道路路基


class RoadBed(object):

    def __init__(self, project_information, _new_path_) -> None:
        self.sheet = None
        self.project_information = project_information
        dir_path = TEMPLATES['道路']['路基']
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        self.FontStyles()
        self.From1()

        self.From2()

        self.DirWorkBook.save(_new_path_)

        self.DirWorkBook.close()

    def FontStyle(self):

        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=7)

    def Write_Sheet(self, number: int, sheet, start_row: int,
                    start_col: int, Range: list):
        """

        :number 需要提供的数量
        :start_row:开始的行数
        :start_col:开始的列数

        """

        z = number // 10  # 整除后需要获取几组的数据对剩下数据的处理
        for x in range(0, z):
            for n in range(0, 10):
                sheet.cell(
                    row=start_row + x,
                    column=start_col + n,
                    value=random.randint(
                        Range[0],
                        Range[1]))

        z1 = number % 10  # 整除后还需要处理多少的数据内容的数据
        for n in range(0, z1):
            sheet.cell(
                row=start_row + z,
                column=start_col + n,
                value=random.randint(
                    Range[0],
                    Range[1]))

    def From1(self):

        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['H5'] = self.project_information['项目名称']

        DIR_SHEET['H6'] = self.project_information['施工单位']

        DIR_SHEET['H7'] = self.project_information['单位工程']

        DIR_SHEET['Z8'] = self.project_information['检验批部位']

        DIR_SHEET['H9'] = self.project_information['道路长度']

        DIR_SHEET['T9'] = self.project_information['项目负责人']

        DIR_SHEET['AF9'] = self.project_information['技术负责人']

        DIR_SHEET['H10'] = self.project_information['资料员']

        DIR_SHEET['T10'] = self.project_information['施工员']

        DIR_SHEET['AF10'] = self.project_information['质量员']

        DIR_SHEET['H11'] = self.project_information['交方班组']

        DIR_SHEET['T11'] = self.project_information['接方班组']

        DIR_SHEET['AF11'] = self.project_information['检验日期']

        if self.project_information['填挖类型'] == '挖方':

            if self.project_information['道路类别'] == '城市快速路、主干路':
                DIR_SHEET['V17'] = '压实度符合设计要求，详见实验报告单，编号：'

            if self.project_information['道路类别'] == '次干路':
                DIR_SHEET['V18'] = '压实度符合设计要求，详见实验报告单，编号：'

            if self.project_information['道路类别'] == '支路及其他小路':
                DIR_SHEET['V19'] = '压实度符合设计要求，详见实验报告单，编号：'

        if self.project_information['填挖类型'] == '填方':

            if self.project_information['路床顶面以下深度'] > 0:

                if self.project_information['道路类别'] == '城市快速路、主干路':
                    DIR_SHEET['V20'] = '压实度符合设计要求，详见实验报告单，编号：'

                if self.project_information['道路类别'] == '次干路':
                    DIR_SHEET['V21'] = '压实度符合设计要求，详见实验报告单，编号：'

                if self.project_information['道路类别'] == '支路及其他小路':
                    DIR_SHEET['V22'] = '压实度符合设计要求，详见实验报告单，编号：'

            if self.project_information['路床顶面以下深度'] > 80:

                if self.project_information['道路类别'] == '城市快速路、主干路':
                    DIR_SHEET['V23'] = '压实度符合设计要求，详见实验报告单，编号：'

                if self.project_information['道路类别'] == '次干路':
                    DIR_SHEET['V24'] = '压实度符合设计要求，详见实验报告单，编号：'

                if self.project_information['道路类别'] == '支路及其他小路':
                    DIR_SHEET['V25'] = '压实度符合设计要求，详见实验报告单，编号：'

            if self.project_information['路床顶面以下深度'] > 150:

                if self.project_information['道路类别'] == '城市快速路、主干路':
                    DIR_SHEET['V23'] = '压实度符合设计要求，详见实验报告单，编号：'

                if self.project_information['道路类别'] == '次干路':
                    DIR_SHEET['V24'] = '压实度符合设计要求，详见实验报告单，编号：'

                if self.project_information['道路类别'] == '支路及其他小路':
                    DIR_SHEET['V25'] = '压实度符合设计要求，详见实验报告单，编号：'

        if self.project_information['弯沉值']:
            DIR_SHEET['I29'] = self.project_information['弯沉值']

            DIR_SHEET['V29'] = '弯沉符合设计要求，详见实验报告单，编号：'

    def From2(self):

        global arg
        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[1]]

        keys = [i for i in range(8, 27)]

        for key in keys:

            # 道路最长不能超过600m

            if key == 8:
                # 路床纵断高程（mm）
                # 道路长度尽量先不超过600m
                number = int(self.project_information['道路长度'] / 20)
                self.Write_Sheet(number, start_row=key,
                                 start_col=23, Range=[-20, 10], sheet=DIR_SHEET)
                DIR_SHEET.cell(row=key, column=33).value = number
                DIR_SHEET.cell(row=key, column=35).value = number
                DIR_SHEET.cell(row=key, column=37).value = number / number

            if key == 11:
                # 路床中线偏位（mm）
                # 道路长度尽量先不超过3000m
                number = int(self.project_information['道路长度'] / 100)
                self.Write_Sheet(
                    number, start_row=key, start_col=23, Range=[
                        0, 30], sheet=DIR_SHEET)
                DIR_SHEET.cell(row=key, column=33).value = number
                DIR_SHEET.cell(row=key, column=35).value = number
                DIR_SHEET.cell(row=key, column=37).value = number / number

            if key == 14:

                # 路床平整度（mm）
                # 道路长度尽量先不超过3000m
                number = int(self.project_information['道路长度'] / 20)
                if self.project_information['每车道路宽'] < 9:
                    arg = 1

                if self.project_information['每车道路宽'] < 15 and self.project_information['每车道路宽'] >= 9:
                    arg = 2

                if self.project_information['每车道路宽'] >= 15:
                    arg = 3

                number2 = number * arg
                self.Write_Sheet(
                    number2, start_row=key, start_col=23, Range=[
                        0, 15], sheet=DIR_SHEET)
                DIR_SHEET.cell(row=key, column=33).value = number2
                DIR_SHEET.cell(row=key, column=35).value = number2
                DIR_SHEET.cell(row=key, column=37).value = number2 / number2

            if key == 17:
                # 路床宽度（mm)
                number = int(self.project_information['道路长度'] / 40)
                self.Write_Sheet(
                    number, start_row=11, start_col=23, Range=[
                        0, 15], sheet=DIR_SHEET)
                DIR_SHEET.cell(row=key, column=33).value = number
                DIR_SHEET.cell(row=key, column=35).value = number
                DIR_SHEET.cell(row=key, column=37).value = number / number

            if key == 19:

                # 路床横坡
                number = int(self.project_information['道路长度'] / 20)

                if self.project_information['每车道路宽'] < 9:
                    arg = 2

                if self.project_information['每车道路宽'] < 15 and self.project_information['每车道路宽'] >= 9:
                    arg = 4

                if self.project_information['每车道路宽'] >= 15:
                    arg = 6

                number2 = number * arg
                self.Write_Sheet(
                    number2, start_row=key, start_col=23, Range=[
                        0, 15], sheet=DIR_SHEET)
                DIR_SHEET.cell(row=key, column=33).value = number2
                DIR_SHEET.cell(row=key, column=35).value = number2
                DIR_SHEET.cell(row=key, column=37).value = number2 / number2

            if key == 22:
                # 边坡
                number = int(self.project_information['道路长度'] / 20)
                self.Write_Sheet(
                    number, start_row=key, start_col=23, Range=[
                        0, 15], sheet=DIR_SHEET)
                DIR_SHEET.cell(row=key, column=33).value = number
                DIR_SHEET.cell(row=key, column=35).value = number
                DIR_SHEET.cell(row=key, column=37).value = number / number

    def FontStyles(self):
        pass


# 砌体检验批验收记录


class MasonryStructures(object):
    """
    适用范围：烧结空心砖、蒸压加气混凝土砌块、轻骨料混凝土小型空心砌块(02020501)

    """

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['主体结构']['填充墙砌体'], ) -> None:

        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '主体结构'
        self.project_information['子分部工程'] = '砌体结构'
        self.project_information['分项工程'] = '填充墙砖体'
        self.inport_sheetname = inport_sheetname
        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        self.dir_path = dir_path

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def JudegeISNULL(self, key):
        if key in self.project_information:
            return self.project_information[key]
        else:
            return ''

    def From1(self):

        global number
        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['P6'] = self.project_information['项目负责人']

        DIR_SHEET['F6'] = self.project_information['施工单位']

        DIR_SHEET['X7'] = self.project_information['检验批部位']

        DIR_SHEET['F7'] = self.project_information['分包单位']

        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['S34'] = str_date(self.JudegeISNULL('时间'))

        DIR_SHEET['X7'] = self.project_information['检验批部位']

        DIR_SHEET['X6'] = self.JudegeISNULL('检验批容量')

        DIR_SHEET['U3'] = f"编号:{self.JudegeISNULL('检验批编号')}"

        self.checknumber = random.randint(5, 10)

        for key in range(100):

            if key == 10:
                DIR_SHEET.cell(
                    row=10, column=13).value = self.project_information['块材强度等级'].replace('MU', '')

                DIR_SHEET.cell(row=10, column=15).value = '全'

                DIR_SHEET.cell(
                    row=10,
                    column=18).value = f"该部位采用{self.project_information['块材类型']},块材强度{self.project_information['块材强度等级']},符合设计强度要求"

                DIR_SHEET.cell(row=10, column=18).font = Font(size=8)

                DIR_SHEET.cell(row=10, column=18).alignment = Alignment(
                    horizontal='left', vertical='center', wrapText=True)

            if key == 12:
                DIR_SHEET.cell(
                    row=key, column=13).value = self.project_information['砂浆强度等级'].replace('M', '')

                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(
                    row=key,
                    column=18).value = f"该部位采用{self.project_information['砂浆类型']},砂浆强度{self.project_information['砂浆强度等级']},符合设计强度要求"

                DIR_SHEET.cell(row=key, column=18).font = Font(size=8)

                DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                    horizontal='left', vertical='center', wrapText=True)

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 14:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(
                    row=key, column=18).value = f"与主体结构连接可靠，其连接构造符合设计要求"

                DIR_SHEET.cell(row=key, column=18).font = Font(size=8)

                DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                    horizontal='left', vertical='center')

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 15:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = "已按照要求进行实体检测"
                DIR_SHEET.cell(row=key, column=18).font = Font(size=8)
                DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                    horizontal='left', vertical='center')
                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 16:

                DIR_SHEET.cell(row=key, column=15).value = self.checknumber

                DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                for n in range(self.checknumber):
                    DIR_SHEET.cell(row=key, column=18 +
                                   n).value = random.randint(1, 10)
                    DIR_SHEET.cell(row=key, column=18 + n).font = Font(size=6)
                    DIR_SHEET.cell(
                        row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')
                for n2 in range(self.checknumber, 10):
                    DIR_SHEET.cell(row=key, column=18 +
                                   n2).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 17:
                if float(self.project_information['层高']) < 3:

                    DIR_SHEET.cell(row=key, column=15).value = self.checknumber

                    DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                    for n in range(self.checknumber):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).value = random.randint(1, 5)
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).font = Font(size=6)
                        DIR_SHEET.cell(
                            row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')

                    for n2 in range(self.checknumber, 10):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '合格'

                else:

                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=18, end_column=27)

                    DIR_SHEET.cell(row=key, column=18).value = '/'
                    DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '/'

            if key == 18:

                if float(self.project_information['层高']) >= 3:

                    DIR_SHEET.cell(row=key, column=15).value = self.checknumber

                    DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                    for n in range(self.checknumber):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).value = random.randint(1, 10)
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).font = Font(size=6)
                        DIR_SHEET.cell(
                            row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')

                    for n2 in range(self.checknumber, 10):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '合格'

                else:

                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=18, end_column=27)

                    DIR_SHEET.cell(row=key, column=18).value = '/'
                    DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '/'

            if key == 19:

                DIR_SHEET.cell(row=key, column=15).value = self.checknumber

                DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                for n in range(self.checknumber):
                    DIR_SHEET.cell(row=key, column=18 +
                                   n).value = random.randint(1, 8)
                    DIR_SHEET.cell(row=key, column=18 + n).font = Font(size=6)
                    DIR_SHEET.cell(
                        row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')

                for n2 in range(self.checknumber, 10):
                    DIR_SHEET.cell(row=key, column=18 +
                                   n2).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 20:

                DIR_SHEET.cell(row=key, column=15).value = self.checknumber

                DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                for n in range(self.checknumber):
                    DIR_SHEET.cell(row=key, column=18 +
                                   n).value = random.randint(-10, 10)
                    DIR_SHEET.cell(row=key, column=18 + n).font = Font(size=6)
                    DIR_SHEET.cell(
                        row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')

                for n2 in range(self.checknumber, 10):
                    DIR_SHEET.cell(row=key, column=18 +
                                   n2).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 21:

                DIR_SHEET.cell(row=key, column=15).value = self.checknumber

                DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                for n in range(self.checknumber):
                    DIR_SHEET.cell(row=key, column=18 +
                                   n).value = random.randint(0, 20)
                    DIR_SHEET.cell(row=key, column=18 + n).font = Font(size=6)
                    DIR_SHEET.cell(
                        row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')

                for n2 in range(self.checknumber, 10):
                    DIR_SHEET.cell(row=key, column=18 +
                                   n2).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 22:

                if judge_part(['空心砖'], self.project_information['块材类型']):

                    DIR_SHEET.cell(row=key, column=15).value = self.checknumber

                    DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                    for n in range(self.checknumber):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).value = f'{random.randint(80, 100)}%'
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).font = Font(size=6)
                        DIR_SHEET.cell(
                            row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')

                    for n2 in range(self.checknumber, 10):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '合格'

                else:

                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=18, end_column=27)

                    DIR_SHEET.cell(row=key, column=18).value = '/'
                    DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '/'

            if key == 23:

                if judge_part(['空心砖'], self.project_information['块材类型']):

                    DIR_SHEET.cell(row=key, column=15).value = '全'

                    DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                    DIR_SHEET.cell(
                        row=key, column=18).value = '填满砂浆,无透明缝、瞎缝、假缝'
                    DIR_SHEET.cell(row=key, column=18).font = Font(size=8)

                    DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                        horizontal='left', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '合格'
                else:

                    DIR_SHEET.cell(row=key, column=18).value = '/'

                    DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                        horizontal='center', vertical='center')
                    DIR_SHEET.cell(row=key, column=28).value = '/'

            if key == 24:

                if judge_part(['蒸压加气混凝土砌块', '轻骨料混凝土小型空心砌块'],
                              self.project_information['块材类型']):

                    DIR_SHEET.cell(row=key, column=15).value = '全'

                    DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                    for n in range(self.checknumber):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).value = f'{random.randint(80, 100)}%'
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).font = Font(size=6)
                        DIR_SHEET.cell(
                            row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')

                    for n2 in range(self.checknumber, 10):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '合格'

                else:

                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=18, end_column=27)

                    DIR_SHEET.cell(row=key, column=18).value = '/'
                    DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '/'

            if key == 25:

                if judge_part(['蒸压加气混凝土砌块', '轻骨料混凝土小型空心砌块'],
                              self.project_information['块材类型']):

                    DIR_SHEET.cell(row=key, column=15).value = '全'

                    DIR_SHEET.cell(row=key, column=18).value = self.checknumber

                    for n in range(self.checknumber):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).value = f'{random.randint(80, 100)}%'
                        DIR_SHEET.cell(row=key, column=18 +
                                       n).font = Font(size=6)
                        DIR_SHEET.cell(
                            row=key, column=18 + n).alignment = Alignment(horizontal='center', vertical='center')

                    for n2 in range(self.checknumber, 10):
                        DIR_SHEET.cell(row=key, column=18 +
                                       n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=18 + n2).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '合格'

                else:

                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=18, end_column=27)

                    DIR_SHEET.cell(row=key, column=18).value = '/'
                    DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=28).value = '/'

            if key == 26:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '拉结钢筋和网片置于灰缝中符合设计要求'

                DIR_SHEET.cell(row=key, column=18).font = Font(size=8)
                DIR_SHEET.cell(row=key, column=28).alignment = Alignment(
                    horizontal='left', vertical='center')
                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 27:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '拉结钢筋和网片埋置长度符合设计要求'

                DIR_SHEET.cell(row=key, column=18).font = Font(size=8)
                DIR_SHEET.cell(row=key, column=28).alignment = Alignment(
                    horizontal='left', vertical='center')

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 28:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(
                    row=key, column=18).value = '已按照要求进行错缝搭砌,搭砌长度符合规范要求'

                DIR_SHEET.cell(row=key, column=18).font = Font(size=8)

                DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                    horizontal='left', vertical='center')
                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 29:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '水平灰缝厚度符合规范要求'

                DIR_SHEET.cell(row=key, column=18).font = Font(size=8)
                DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                    horizontal='left', vertical='center')

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 30:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '竖向灰缝宽度符合规范要求'

                DIR_SHEET.cell(row=key, column=18).font = Font(size=8)
                DIR_SHEET.cell(row=key, column=18).alignment = Alignment(
                    horizontal='left', vertical='center')

                DIR_SHEET.cell(row=key, column=28).value = '合格'


class UniversalPlastering(object):

    def __init__(self, project_information, inport_sheetname) -> None:
        self.FontStyle2 = None
        self.FontStyle = None
        self.FontStyle1 = None
        self.sheet = None

        self.inport_sheetname = inport_sheetname

        self.project_information = project_information

        self.project_information['分部工程'] = '建筑装饰装修'
        self.project_information['子分部工程'] = '抹灰'
        self.project_information['分项工程'] = '一般抹灰'

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        if self.project_information['抹灰位置'] == '室外':
            self.CheckQuantity = int(
                int(float(self.project_information['抹灰工程量'])) / 100)
            self.CheckCapacity = f"{int(self.project_information['抹灰工程量'])}平方"
        if self.project_information['抹灰位置'] == '室内':
            self.CheckQuantity = int(
                int(int(self.project_information['抹灰房间数'])) / 50)
            self.CheckCapacity = f"{int(self.project_information['抹灰房间数'])}间"

        if self.project_information['抹灰位置'] == '走廊':
            self.CheckQuantity = int(
                int(self.project_information['抹灰工程量']) / 30)  # 经验批数量
            # 检验批容量
            self.CheckCapacity = f"{int(self.project_information['抹灰工程量'])}平方"

        dir_path = TEMPLATES['建筑装饰装修']['一般抹灰']

        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)

        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        self.FontStyles()
        self.From1()

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):

        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=8)
        self.FontStyle2 = Font(size=9)

    def From1(self):

        # 表头

        global DirRange

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G5'] = f"{self.project_information['项目名称']}" \
                          f"({self.project_information['单位工程']})"

        DIR_SHEET['P6'] = self.project_information['项目负责人']

        DIR_SHEET['G6'] = self.project_information['施工单位']

        DIR_SHEET['U7'] = self.project_information['检验批部位']

        DIR_SHEET['G7'] = self.project_information['分包单位']

        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['R30'] = str_date(self.project_information['时间'])

        DIR_SHEET['S3'] = f"编号:{self.project_information['检验批编号']}"

        DIR_SHEET['U6'] = self.CheckCapacity

        number1 = random.randint(3, 5)

        for key in range(100):

            if key == 10:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = '已按照要求检查相关文件符合要求'

                DIR_SHEET.cell(row=key, column=22).value = '合格'

            if key == 11:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = '已按照要求进行洒水润湿,进行界面处理'

                DIR_SHEET.cell(row=key, column=22).value = '合格'

            if key == 12:  # 抹灰处的钢丝网片的安装需要检查隐蔽验收记录
                # 第4.2.3条 抹灰工程应分层进行。当抹灰总厚度大于或等于35mm时，
                # 应采取强措施。不同材料基体交接处表面的抹灰，应采用开裂的加强措施，
                # 当采用假期加强网时，加强网与各基体的搭接宽度不应小于100mm
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = '不同材料基体交接处表面的抹灰，' \
                                                           '已按照要求采用开裂的加强措施'

                DIR_SHEET.cell(row=key, column=22).value = '合格'

            if key == 13:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '抹灰层与基层之间及各抹灰层之间粘结牢固'

                DIR_SHEET.cell(row=key, column=22).value = '合格'

            if key == 14:

                if self.project_information['抹灰类型'] == '一般抹灰':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(
                        row=key, column=17).value = '光滑、洁净、接槎平整,分格缝清晰'

                    DIR_SHEET.cell(row=key, column=22).value = '合格'

                if self.project_information['抹灰类型'] == '高级抹灰':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(
                        row=key, column=17).value = '光滑、洁净、颜色均匀,分格缝和灰线应清晰美观'

                    DIR_SHEET.cell(row=key, column=22).value = '合格'

            if key == 15:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = '槽盒周围的抹灰表面'

                DIR_SHEET.cell(row=key, column=22).value = '合格'

            if key == 16:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = '抹灰层的总厚度符合设计要求'

                DIR_SHEET.cell(row=key, column=22).value = '合格'

            if key == 17:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = '抹灰层分格缝的设置符合设计要求,' \
                                                           '宽度深度均匀,表面光滑'

                DIR_SHEET.cell(row=key, column=22).value = '合格'
            if key == 18:
                number = random.randint(3, 10)

                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=16).value = number

                DIR_SHEET.cell(
                    row=key, column=17).value = f'检查{number}处,合格{number}处,符合要求'

                DIR_SHEET.cell(row=key, column=22).value = '合格'

            if key == 21:

                if self.project_information['抹灰类型'] == '一般抹灰':
                    DIR_SHEET.cell(row=key, column=9).value = '√'

                if self.project_information['抹灰类型'] == '高级抹灰':
                    DIR_SHEET.cell(row=key, column=12).value = '√'

            if key == 22 or key == 23 or key == 24 or key == 25 or key == 26:

                if self.project_information['抹灰类型'] == '一般抹灰':
                    DirRange = 4
                if self.project_information['抹灰类型'] == '高级抹灰':
                    DirRange = 3

                DIR_SHEET.cell(row=key, column=14).value = number1

                DIR_SHEET.cell(row=key, column=16).value = number1

                for n in range(number1):
                    number = random.randint(0, DirRange)
                    DIR_SHEET.cell(row=key, column=17 + n).value = number

                DIR_SHEET.cell(row=key, column=22).value = '合格'


# 金属门窗安装


class AluminiumWindows(object):
    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑装饰装修']['铝合金门窗']) -> None:
        self.project_information = project_information
        print(self.project_information)
        self.project_information['分部工程'] = "建筑装饰装修"
        self.project_information['子分部工程'] = '门窗'
        self.project_information['分项工程'] = '金属门窗安装'

        self.inport_sheetname = inport_sheetname
        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        self.dir_path = dir_path

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):
        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=8)
        self.FontStyle2 = Font(size=9)

    def From1(self):
        # 表头

        global number
        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G5'] = f"{self.project_information['项目名称']}" + \
                          "({self.project_information['单位工程']})"

        DIR_SHEET['P6'] = self.project_information['项目负责人']

        DIR_SHEET['G6'] = self.project_information['施工单位']

        DIR_SHEET['Y7'] = self.project_information['检验批部位']

        DIR_SHEET['G7'] = self.project_information['分包单位']

        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['Y6'] = f"{int(self.project_information['门窗扇数量'])}扇"

        if int(self.project_information['门窗扇数量']) > 10:
            number = int(self.project_information['门窗扇数量'] * 0.1)

        if int(self.project_information['门窗扇数量']) < 10:
            number = random.randint(3, int(self.project_information['门窗扇数量']))

        self.project_information['门窗槽口对角线长度差'] = (int(self.project_information['门窗槽口宽度']) ** 2
                                                  + int(self.project_information['门窗槽口宽度']) ** 2) ** 0.5

        for key in range(100):

            if key == 10:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = '已按照要求检查相关文件符合要求'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 11:  # 金属门窗框的安装需要隐蔽

                DIR_SHEET.cell(row=key, column=14).value = '全'
                #
                DIR_SHEET.cell(row=key, column=17).value = '金属门窗扇的安装和附框的安装牢固可靠'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 12:
                DIR_SHEET.cell(row=key, column=14).value = '全'
                #
                DIR_SHEET.cell(row=key, column=17).value = '金属门窗扇的安装牢固可靠'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 13:
                # 金属门窗配件的型号规格数量

                DIR_SHEET.cell(row=key, column=14).value = '全'
                #
                DIR_SHEET.cell(
                    row=key, column=17).value = '金属门窗配件的型号规格数量符合设计要求'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 14:
                DIR_SHEET.cell(row=key, column=14).value = '全'
                #
                DIR_SHEET.cell(
                    row=key, column=17).value = '金属门窗表面洁净平整光滑色泽一致,无锈蚀'

                DIR_SHEET.cell(row=key, column=27).value = '合格'
            if key == 15:
                DIR_SHEET.cell(row=key, column=14).value = '全'
                #
                DIR_SHEET.cell(
                    row=key, column=17).value = '金属门窗推拉门窗扇开关力大于50N'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 16:
                DIR_SHEET.cell(row=key, column=14).value = '全'
                #
                DIR_SHEET.cell(
                    row=key, column=17).value = '金属门窗框与墙体之间的缝隙填嵌饱满'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 17:
                DIR_SHEET.cell(row=key, column=14).value = '全'
                #
                DIR_SHEET.cell(
                    row=key, column=17).value = '金属门窗扇的密封胶条装配完整且完好'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 18:
                DIR_SHEET.cell(row=key, column=14).value = '全'
                #
                DIR_SHEET.cell(
                    row=key, column=17).value = '排水孔畅通,位置和数量符合设计要求'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 19:

                if int(self.project_information['门窗槽口宽度']) < 1500 or \
                        int(self.project_information['门窗槽口高度']) < 1500:

                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=16).value = number

                    for n in range(number):
                        DIR_SHEET.cell(
                            row=key,
                            column=17 +
                            n).value = random.randint(
                            0,
                            2)

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=17, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 20:

                if int(self.project_information['门窗槽口宽度']) >= 1500 or \
                        int(self.project_information['门窗槽口高度']) >= 1500:

                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=16).value = number

                    for n in range(number):
                        DIR_SHEET.cell(
                            row=key,
                            column=17 +
                            n).value = random.randint(
                            0,
                            3)

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=17, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 21:

                if self.project_information['门窗槽口对角线长度差'] < 2000:

                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=16).value = number

                    for n in range(number):
                        DIR_SHEET.cell(
                            row=key,
                            column=17 +
                            n).value = random.randint(
                            0,
                            4)

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:

                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=17, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 22:

                if self.project_information['门窗槽口对角线长度差'] >= 2000:

                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=16).value = number

                    for n in range(number):
                        DIR_SHEET.cell(
                            row=key,
                            column=17 +
                            n).value = random.randint(
                            0,
                            5)

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:

                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=17, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 23:

                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=16).value = number

                for n in range(number):
                    DIR_SHEET.cell(
                        row=key,
                        column=17 +
                        n).value = random.randint(
                        0,
                        2)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 24:

                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=16).value = number

                for n in range(number):
                    DIR_SHEET.cell(
                        row=key,
                        column=17 +
                        n).value = random.randint(
                        0,
                        2)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 25:

                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=16).value = number

                for n in range(number):
                    DIR_SHEET.cell(
                        row=key,
                        column=17 +
                        n).value = random.randint(
                        0,
                        5)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 26:

                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=16).value = number

                for n in range(number):
                    DIR_SHEET.cell(
                        row=key,
                        column=17 +
                        n).value = random.randint(
                        0,
                        5)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 27:

                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=16).value = number

                for n in range(number):
                    DIR_SHEET.cell(
                        row=key,
                        column=17 +
                        n).value = random.randint(
                        0,
                        4)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 28:

                if judge_part(['门'], self.project_information['检验批部位']):

                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=16).value = number

                    for n in range(number):
                        DIR_SHEET.cell(
                            row=key,
                            column=17 +
                            n).value = random.randint(
                            0,
                            2)

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=17, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 29:

                if judge_part(['门'], self.project_information['检验批部位']):

                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=16).value = number

                    for n in range(number):
                        DIR_SHEET.cell(
                            row=key,
                            column=17 +
                            n).value = random.randint(
                            0,
                            1)

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.merge_cells(
                        start_row=key, end_row=key, start_column=17, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(row=key, column=27).value = '/'


class WaterBasedCoating(object):
    # 1000平方一个检验批
    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑装饰装修']['水性涂料']) -> None:

        global check_umber
        self.project_information = project_information

        self.project_information['分部工程'] = '建筑装饰装修'
        self.project_information['子分部工程'] = '涂饰'
        self.project_information['分项工程'] = '水性涂料涂饰'

        if self.project_information['涂料位置'] == '室内':

            self.project_information['检验批容量'] = str(
                self.project_information['室内涂料房间数量']) + '间'
            try:
                check_umber = int(
                    int(self.project_information['室内涂料房间数量']) * 0.1)
            except BaseException:
                print(f"{self.project_information['检验批部位']}请填写房间数量")

        if self.project_information['涂料位置'] == '室外':

            self.project_information['检验批容量'] = str(
                self.project_information['室外涂料平方数']) + '平方米'

            try:
                check_umber = int(
                    int(self.project_information['室外涂料平方数']) / 100)
            except BaseException:
                print(f"{self.project_information['检验批部位']}室外涂饰工程的平方数")

        if check_umber < 3:

            self.check_umber = random.randint(3, 5)
        else:
            self.check_umber = random.randint(3, check_umber)

        self.project_information = project_information

        self.inport_sheetname = inport_sheetname
        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()
        self.From2()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):
        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=8)
        self.FontStyle2 = Font(size=9)

    def From1(self):
        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['P6'] = self.project_information['项目负责人']

        DIR_SHEET['G6'] = self.project_information['施工单位']

        DIR_SHEET['Y7'] = self.project_information['检验批部位']

        DIR_SHEET['G7'] = self.project_information['分包单位']

        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['U3'] = f"编号:{self.project_information['检验批编号']}"
        DIR_SHEET['U3'].font = Font(size=8)

        DIR_SHEET['Y6'] = self.project_information['检验批容量']

        self.CheckRange = {
            '薄涂料': {
                '普通涂饰': [3, 3, 3, 2, 2],
                '高级涂饰': [2, 2, 2, 1, 1]
            },
            '厚涂料': {
                '普通涂饰': [4, 4, 4, 2, 2],
                '高级涂饰': [3, 3, 3, 1, 1]
            },
            '复层涂料': [5, 5, 4, 3, 3]
        }

        for key in range(100):

            if key == 10:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '涂料品种、型号、性能符合设计要求'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 11:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '涂饰颜色、光泽、图案符合设计要求'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 12:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = '涂饰综合质量符合设计要求'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 13:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '涂饰工程的基层处理符合设计要求'

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 14:

                if self.project_information['涂饰级别'] == '普通涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '颜色均匀一致'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 15:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '颜色均匀一致'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 16:

                if self.project_information['涂饰级别'] == '普通涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(
                        row=key, column=17).value = '光泽基本均匀，光滑无挡手感'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 17:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(
                        row=key, column=17).value = '光泽基本均匀，光滑无挡手感'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 18:

                if self.project_information['涂饰级别'] == '普通涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    if random.random() > 0.75:
                        DIR_SHEET.cell(
                            row=key, column=17).value = '少量轻微泛碱、咬色'

                    DIR_SHEET.cell(row=key, column=17).value = '无泛碱、咬色'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 19:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '无泛碱、咬色'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 20:

                if self.project_information['涂饰级别'] == '普通涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    if random.random() > 0.75:
                        DIR_SHEET.cell(
                            row=key, column=17).value = '少量轻微流坠、疙瘩'

                    DIR_SHEET.cell(row=key, column=17).value = '无泛碱、咬色'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 21:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '无流坠、疙瘩'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 22:

                if self.project_information['涂饰级别'] == '普通涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    if random.random() > 0.75:
                        DIR_SHEET.cell(
                            row=key, column=17).value = '存在少量轻微砂眼、刷纹通顺'

                    DIR_SHEET.cell(row=key, column=17).value = '无砂眼，无刷纹'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 23:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '薄涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '无砂眼，无刷纹'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 24:

                if self.project_information['涂饰级别'] == '普通涂饰' and self.project_information[
                        '涂饰类型'] == '厚涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '颜色均匀一致'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 25:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '厚涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '颜色均匀一致'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 26:

                if self.project_information['涂饰级别'] == '普通涂饰' and self.project_information[
                        '涂饰类型'] == '厚涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(
                        row=key, column=17).value = '光泽基本均匀，光滑无挡手感'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 27:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '厚涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(
                        row=key, column=17).value = '光泽基本均匀，光滑无挡手感'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 28:

                if self.project_information['涂饰级别'] == '普通涂饰' and self.project_information[
                        '涂饰类型'] == '厚涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    if random.random() > 0.75:
                        DIR_SHEET.cell(
                            row=key, column=17).value = '少量轻微泛碱、咬色'

                    DIR_SHEET.cell(row=key, column=17).value = '无泛碱、咬色'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 29:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '厚涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '无泛碱、咬色'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 30:

                if self.project_information['涂饰级别'] == '高级涂饰' and self.project_information[
                        '涂饰类型'] == '厚涂料':
                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = '疏密均匀'

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'

    def From2(self):

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[1]]
        DIR_SHEET['Y3'] = f"编号:{self.project_information['检验批编号']}"
        DIR_SHEET['Y3'].font = Font(size=8)
        DIR_SHEET['x23'] = str_date(self.project_information['时间'])
        for key in range(100):

            if key == 6:

                if self.project_information['涂饰类型'] == '复层涂料':
                    DIR_SHEET.cell(row=key, column=19).value = '全'

                    DIR_SHEET.cell(row=key, column=22).value = '颜色均匀一致'

                    DIR_SHEET.cell(row=key, column=32).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=22).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=22).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=32).value = '/'

            if key == 7:
                if self.project_information['涂饰类型'] == '复层涂料':
                    DIR_SHEET.cell(row=key, column=19).value = '全'

                    DIR_SHEET.cell(row=key, column=22).value = '光泽基本均匀'

                    DIR_SHEET.cell(row=key, column=32).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=22).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=22).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=32).value = '/'

            if key == 8:
                if self.project_information['涂饰类型'] == '复层涂料':
                    DIR_SHEET.cell(row=key, column=19).value = '全'

                    DIR_SHEET.cell(row=key, column=22).value = '无泛碱、咬色'

                    DIR_SHEET.cell(row=key, column=32).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=22).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=22).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=32).value = '/'

            if key == 9:

                if self.project_information['涂饰类型'] == '复层涂料':
                    DIR_SHEET.cell(row=key, column=19).value = '全'

                    DIR_SHEET.cell(row=key, column=22).value = '喷点均匀，不存在连片现象'

                    DIR_SHEET.cell(row=key, column=32).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=22).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=22).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=32).value = '/'

            if key == 10:
                DIR_SHEET.cell(row=key, column=19).value = '全'

                DIR_SHEET.cell(
                    row=key, column=22).value = '涂料与其他装修材料和设备衔接处吻合，界面清晰'

                DIR_SHEET.cell(row=key, column=32).value = '合格'

            if key == 14:

                if self.project_information['涂饰类型'] == '薄涂料':

                    if self.project_information['涂饰级别'] == '普通涂饰':
                        DIR_SHEET.cell(row=key, column=9).value = '√'

                    if self.project_information['涂饰级别'] == '高级涂饰':
                        DIR_SHEET.cell(row=key, column=11).value = '√'

                if self.project_information['涂饰类型'] == '厚涂料':

                    if self.project_information['涂饰级别'] == '普通涂饰':
                        DIR_SHEET.cell(row=key, column=13).value = '√'

                    if self.project_information['涂饰级别'] == '高级涂饰':
                        DIR_SHEET.cell(row=key, column=15).value = '√'

                if self.project_information['涂饰类型'] == '复层涂料':
                    DIR_SHEET.cell(row=key, column=17).value = '√'

            if key == 15 \
                    or key == 16 \
                    or key == 17 \
                    or key == 18 \
                    or key == 19:

                DIR_SHEET.cell(row=key, column=19).value = self.check_umber

                DIR_SHEET.cell(row=key, column=21).value = self.check_umber

                for n in range(self.check_umber):  # 这里的内容问题还需要解决
                    if self.project_information['涂饰类型'] == '薄涂料' \
                            or self.project_information['涂饰类型'] == '厚涂料':
                        DIR_Range = self.CheckRange[self.project_information['涂饰类型']][
                            self.project_information['涂饰级别']]
                    else:
                        DIR_Range = self.CheckRange[self.project_information['涂饰类型']]
                    col = key - 15  # [3, 3, 3, 2, 2]
                    DIR_SHEET.cell(
                        row=key,
                        column=22 +
                        n).value = random.randint(
                        0,
                        DIR_Range[col])
                    DIR_SHEET.cell(
                        row=key,
                        column=22 +
                        n).alignment = Alignment(horizontal='center', vertical='center')
                    DIR_SHEET.cell(
                        row=key,
                        column=22 +
                        n).font = Font(size=8)

                for n2 in range(self.check_umber, 10):
                    DIR_SHEET.cell(row=key, column=22 + n2).value = '/'

                DIR_SHEET.cell(row=key, column=32).value = '合格'


class PlateShaped(object):
    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑装饰装修']['板状面层吊顶']) -> None:

        self.project_information = project_information

        self.project_information['分部工程'] = '建筑装饰装修'

        self.project_information['子分部工程'] = '吊顶'

        self.project_information['分项工程'] = '暗龙骨吊顶'

        self.inport_sheetname = inport_sheetname
        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        self.dir_path = dir_path

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def From1(self):
        self.FontStyle1 = Font(size=8)

        self.align = Alignment(horizontal='center',
                               vertical='center', wrap_text=True)

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['G5'].font = self.FontStyle1

        DIR_SHEET['G5'].alignment = self.align

        DIR_SHEET['Q6'] = self.project_information['项目负责人']

        DIR_SHEET['G6'] = self.project_information['施工单位']

        DIR_SHEET['Q6'].font = self.FontStyle1

        DIR_SHEET['Q6'].alignment = self.align

        DIR_SHEET['Z7'] = self.project_information['检验批部位']

        DIR_SHEET['G7'] = self.project_information['分包单位']

        DIR_SHEET['G7'].font = self.FontStyle1

        DIR_SHEET['G7'].alignment = self.align

        DIR_SHEET['Q7'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['T3'] = f"编号:{self.project_information['检验批编号']}"

        DIR_SHEET['V3'].font = Font(size=9)

        DIR_SHEET['Z6'] = f"{self.project_information['吊顶房间数']}间"
        if int(self.project_information['吊顶房间数']) * 0.1 < 3:
            self.check_umber = random.randint(3, 5)

        if int(self.project_information['吊顶房间数']) * 0.1 > 3:
            self.check_umber = random.randint(
                int(int(self.project_information['吊顶房间数']) * 0.1), 10)

        self.CHECkRANGE = {
            '石膏板': {'列号': 7,
                    '范围': [3, 3, 1]},

            '金属板': {'列号': 9,
                    '范围': [2, 2, 1]},
            '岩棉板': {'列号': 11,
                    '范围': [3, 3, 2]},
            '木板、塑料板、玻璃板、复合板': {'列号': 13,
                               '范围': [2, 3, 4]}
        }

        for key in range(100):

            if key == 10:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '吊顶标高尺寸起拱造型符合设计要求'

                DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=18).alignment = self.align

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 11:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(
                    row=key, column=18).value = '面层材料的材质品种、规格、图案、颜色、性能符合设计要求'

                DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=18).alignment = self.align

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 12:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '面板安装符合设计要求'

                DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 13:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(
                    row=key, column=18).value = '吊杆和龙骨的材质、规格、安装及连接方式符合设计要求'

                DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=18).alignment = self.align

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 14:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '面层材料表面质量'

                DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=18).alignment = self.align

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 15:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '面层材料表面质量'

                DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=18).alignment = self.align

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 16:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(row=key, column=18).value = '面板上的灯具、烟感器、检修口位置合理'

                DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=18).alignment = self.align

                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 17:

                if self.project_information['龙骨类型'] == '金属龙骨':
                    DIR_SHEET.cell(row=key, column=15).value = '全'

                    DIR_SHEET.cell(
                        row=key, column=18).value = '金属龙骨的接缝平整吻合颜色一致'

                    DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                    DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 18:
                DIR_SHEET.cell(row=key, column=15).value = '全'

                DIR_SHEET.cell(
                    row=key, column=18).value = '吊顶内吸声材料的品种和铺设厚度符合设计要求'

                DIR_SHEET.cell(row=key, column=18).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=18).alignment = self.align
                DIR_SHEET.cell(row=key, column=28).value = '合格'

            if key == 21:
                col = self.CHECkRANGE[self.project_information['吊顶类型']]['列号']

                DIR_SHEET.cell(row=key, column=col).value = '√'

                DIR_SHEET.cell(row=key, column=col).alignment = self.align

            if key == 22 or key == 23 or key == 24:

                for n in range(self.check_umber):  # number看检查数量

                    DIR_SHEET.cell(row=key, column=15).value = self.check_umber

                    DIR_SHEET.cell(row=key, column=17).value = self.check_umber

                    RANGE = self.CHECkRANGE[self.project_information['吊顶类型']
                                            ]['范围'][key - 22]

                    DIR_SHEET.cell(row=key, column=18 +
                                   n).value = random.randint(0, RANGE * 10) / 10

                    DIR_SHEET.cell(
                        row=key, column=18 + n).alignment = self.align

                    DIR_SHEET.cell(row=key, column=18 +
                                   n).font = Font(size=7, bold=True)

                    DIR_SHEET.cell(row=key, column=28).value = '合格'


class MetalFlooring(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑装饰装修']['板状面层铺设(金属地板)']) -> None:

        # 读入基础的参数
        self.project_information = project_information

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)

        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def From1(self):

        self.FontStyle1 = Font(size=8)

        self.align = Alignment(horizontal='center',
                               vertical='center', wrap_text=True)

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['G5'].font = self.FontStyle1

        DIR_SHEET['G5'].alignment = self.align

        DIR_SHEET['P6'] = self.project_information['项目负责人']

        DIR_SHEET['G6'] = self.project_information['施工单位']

        DIR_SHEET['Q6'].font = self.FontStyle1

        DIR_SHEET['Q6'].alignment = self.align

        DIR_SHEET['Z7'] = self.project_information['检验批部位']

        DIR_SHEET['G7'] = self.project_information['分包单位']

        DIR_SHEET['G7'].font = self.FontStyle1

        DIR_SHEET['G7'].alignment = self.align

        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']

        if int(self.project_information['房间数']) * 0.1 < 3:
            self.chenckcount = random.randint(3, 5)

        if int(self.project_information['房间数']) * 0.1 >= 3:
            self.chenckcount = random.randint(
                int(int(self.project_information['房间数']) * 0.1), 10)

        for key in range(100):

            if key == 10:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = f"金属板的规格型号、厚度、长度、宽度、数量、安装方式符合设计要求。"

                DIR_SHEET.cell(row=key, column=17).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=17).alignment = Alignment(
                    horizontal='left', vertical='center', wrap_text=True)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 11:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = f"面层与基层的固定方法、面层的接缝处理符合设计要求。"

                DIR_SHEET.cell(row=key, column=17).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=17).alignment = Alignment(
                    horizontal='left', vertical='center', wrap_text=True)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 12:

                if self.project_information['接缝处理'] == '焊接':

                    DIR_SHEET.cell(row=key, column=14).value = '全'

                    DIR_SHEET.cell(row=key, column=17).value = f"焊接质量符合设计要求"
                    DIR_SHEET.cell(row=key, column=17).font = self.FontStyle1

                    DIR_SHEET.cell(row=key, column=17).alignment = Alignment(
                        horizontal='left', vertical='center', wrap_text=True)

                    DIR_SHEET.cell(row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(row=key, column=27).value = '/'

            if key == 13:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = f"面层与基层的结合牢固，无翘边、松动、空鼓"

                DIR_SHEET.cell(row=key, column=17).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=17).alignment = Alignment(
                    horizontal='left', vertical='center', wrap_text=True)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 14:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(row=key, column=17).value = f"金属板表面无裂痕、刮伤、脱漆"

                DIR_SHEET.cell(row=key, column=17).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=17).alignment = Alignment(
                    horizontal='left', vertical='center', wrap_text=True)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 15:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = f"面层应平整、洁净、色泽一致，接缝应均匀，周边应顺直。"

                DIR_SHEET.cell(row=key, column=17).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=17).alignment = Alignment(
                    horizontal='left', vertical='center', wrap_text=True)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 16:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = f"镶边用料及尺寸符合设计要求，边角整齐"

                DIR_SHEET.cell(row=key, column=17).font = self.FontStyle1

                DIR_SHEET.cell(row=key, column=17).alignment = Alignment(
                    horizontal='left', vertical='center', wrap_text=True)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 17:
                DIR_SHEET.cell(row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key,
                    column=17).value = f"踢脚线表面洁净，与柱、墙面的结合牢固。踢脚线高度及出柱、墙厚度符合设计要求，且均匀一致"

                DIR_SHEET.cell(row=key, column=17).font = Font(size=7)

                DIR_SHEET.cell(row=key, column=17).alignment = Alignment(
                    horizontal='left', vertical='center', wrap_text=True)

                DIR_SHEET.cell(row=key, column=27).value = '合格'

            if key == 18 or key == 19 or key == 20 or key == 21 or key == 22:

                RANGE = [1, 2, 0.5, 1, 1]

                DIR_SHEET.cell(row=key, column=14).value = self.chenckcount

                DIR_SHEET.cell(row=key, column=16).value = self.chenckcount

                for n in range(self.chenckcount):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, RANGE[key - 18] * 10) / 10
                    DIR_SHEET.cell(row=key, column=17 +
                                   n).font = Font(size=7, bold=True)

                    DIR_SHEET.cell(row=key, column=17 + n).alignment = Alignment(
                        horizontal='center', vertical='center', wrap_text=True)

                DIR_SHEET.cell(row=key, column=27).value = '合格'


class LightningProtection(object):
    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑电气']['防雷引下线及接闪器的安装']) -> None:
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑电气'
        self.project_information['子分部工程'] = '防雷及接地安装'
        self.project_information['分项工程'] = '防雷引下线及接闪器的安装'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        self.FontStyles()
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):

        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=7)

    def From1(self):

        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F6'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['X8'] = self.project_information['项目负责人']

        DIR_SHEET['E8'] = self.project_information['施工单位']

        DIR_SHEET['X7'] = self.project_information['检验批部位']

        DIR_SHEET['E10'] = self.project_information['分包单位']

        DIR_SHEET['M10'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['M8'] = self.project_information['施工员']

        DIR_SHEET['N4'] = f"编号{self.project_information['检验批编号']}"

        DIR_SHEET['T26'] = str_date(self.project_information['时间'])

        self.project_information['检查数量'] = random.randint(3, 10)

        for key in range(12, 100):

            if key == 12:
                # 防雷引下线的布置、安装数量和连接方式

                DIR_SHEET.cell(
                    row=key,
                    column=8).value = f"{self.project_information['检验批部位']}避雷引下线采用{self.project_information['安装数量']}处,采用{self.project_information['防雷引下线与接地装置连接方式']}连接方式与室外接地装置连接"
                DIR_SHEET.cell(
                    row=key,
                    column=8).font = Font(size=8)
                DIR_SHEET.cell(row=key, column=19).value = '同意施工单位自检结果,符合要求'

            if key == 13:
                # 接闪器的布置、规格及数量
                DIR_SHEET.cell(
                    row=key, column=8).value = self.project_information['接闪器的布置内容']

                DIR_SHEET.cell(row=key, column=19).value = '同意施工单位自检结果,符合要求'

            if key == 14:
                # 接闪器与防雷引下线连接方式(焊接/卡接器)
                # 防雷引下线与接地装置连接方式(焊接/螺栓连接)

                DIR_SHEET.cell(
                    row=key,
                    column=8).value = f"接闪器与防雷引下线按要求采用{self.project_information['接闪器与防雷引下线连接方式']}连接," \
                                      f"防雷引下线与接地装置按要求采用{self.project_information['防雷引下线与接地装置连接方式']}"
                DIR_SHEET.cell(
                    row=key, column=19).value = '同意施工单位自检结果,符合要求'

            if key == 15:
                DIR_SHEET.cell(
                    row=key,
                    column=8).value = f"接闪器与防雷引下线按要求采用{self.project_information['接闪器与防雷引下线连接方式']}连接," \
                                      f"防雷引下线与接地装置按要求采用{self.project_information['防雷引下线与接地装置连接方式']}"
                DIR_SHEET.cell(
                    row=key, column=19).value = '同意施工单位自检结果,符合要求'

            if key == 16:
                DIR_SHEET.cell(
                    row=key,
                    column=8).value = f"接闪器与防雷引下线按要求采用{self.project_information['接闪器与防雷引下线连接方式']}连接," \
                                      f"防雷引下线与接地装置按要求采用{self.project_information['防雷引下线与接地装置连接方式']}"

                DIR_SHEET.cell(
                    row=key,
                    column=8).font = Font(size=7)
                DIR_SHEET.cell(
                    row=key, column=19).value = '同意施工单位自检结果,符合要求'

                DIR_SHEET.cell(
                    row=key,
                    column=19).font = Font(
                    size=7)

                DIR_SHEET.cell(
                    row=key, column=19).alignment = Alignment(
                    horizontal='center', vertical='center')

            if key == 17:
                if JudgeBool(self.project_information['是否存在幕墙']):
                    DIR_SHEET.cell(row=key, column=8).value = '幕墙金属框架和建筑物的金属门窗与防雷引下线的连接符合设计要求、' \
                                                              '连接处的防腐蚀措施符合施工要求'
                    DIR_SHEET.cell(
                        row=key, column=19).value = '同意施工单位的自检结果,符合规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).font = Font(
                        size=7)

                    DIR_SHEET.cell(
                        row=key, column=19).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 18:
                DIR_SHEET.cell(
                    row=key, column=8).value = '接闪杆、接闪线、接闪网和接闪带的安装位置、方式符合设计及规范要求'
                DIR_SHEET.cell(
                    row=key, column=8).font = Font(size=7)
                DIR_SHEET.cell(
                    row=key, column=8).alignment = Alignment(horizontal='center', vertical='center', wrapText=True)

                DIR_SHEET.cell(row=key, column=19).value = '同意施工单位的自检结果,符合规范要求'

                DIR_SHEET.cell(
                    row=key,
                    column=19).font = Font(
                    size=7, )

                DIR_SHEET.cell(
                    row=key, column=19).alignment = Alignment(
                    horizontal='center', vertical='center')

            if key == 19:
                DIR_SHEET.cell(row=key, column=8).value = '防雷引下线搭接长度及要求符合规范要求'

                DIR_SHEET.cell(row=key, column=19).value = '同意施工单位的自检结果,符合规范要求'

            if key == 20:
                DIR_SHEET.cell(row=key, column=8).value = '接闪线和接闪带的安装符合设计及规范要求'

                DIR_SHEET.cell(row=key, column=19).value = '同意施工单位的自检结果,符合规范要求'

            if key == 21:
                DIR_SHEET.cell(row=key, column=8).value = '补偿措施安装合格，符合设计及规范要求'

                DIR_SHEET.cell(row=key, column=19).value = '同意施工单位的自检结果,符合规范要求'

            if key == 22:
                DIR_SHEET.cell(row=key, column=8).value = '完整'

                DIR_SHEET.cell(row=key, column=19).value = '完整'

            if key == 23:
                DIR_SHEET.cell(row=key, column=8).value = '符合要求'
                DIR_SHEET.cell(row=key, column=19).value = '符合要求'


class ConduitLaying(object):

    def __init__(self, project_information: dict, inport_sheetname,
                 dir_path=TEMPLATES['建筑电气']['电线导管穿线和敷设']) -> None:
        """

        @type project_information: dict
        """
        self.FontStyle2 = Font(size=9)
        self.FontStyle1 = Font(size=8)
        self.FontStyle = Font(size=7)
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑电气'
        self.project_information['子分部工程'] = '电气照明安装'
        self.project_information['分项工程'] = '电线、电缆导管和线槽敷设'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def From1(self):

        # 表头

        global number
        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F6'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['X8'] = self.project_information['项目负责人']

        DIR_SHEET['E8'] = self.project_information['施工单位']

        DIR_SHEET['X7'] = self.project_information['检验批部位']

        DIR_SHEET['E10'] = self.project_information['分包单位']

        DIR_SHEET['M10'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['M8'] = self.project_information['施工员']

        DIR_SHEET['Q4'] = f"编号： {self.project_information['检验批编号']}"

        # DIR_SHEET['X10'] = self.project_information['建筑电气施工组长']

        for key in range(12, 100):

            if key == 12:
                """
                同一交流回路的绝缘导线不应敷设于不同的金属槽盒内或穿于不同金属导管内。
                检查数量:按每个检验批的配线总回路数抽查20%,且不得少于1个回路
                """

                if self.project_information['配电总回路数（选填）']:

                    if int(self.project_information['配电总回路数（选填）']) * 0.2 > 1:
                        number = int(
                            int(self.project_information['配电总回路数（选填）']) * 0.2)

                else:
                    number = random.randint(3, 10)

                DIR_SHEET.cell(row=key,
                               column=8).value = f'经检查{number}处,合格{number}处,同一交流回路的绝缘导线敷设于不同的金属槽盒内或穿于不同金属导管内'

                DIR_SHEET.cell(row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            if key == 13:
                """
                除设计要求以外,不同回路、不同电压等级和交流与直流 线路的绝缘导线不应穿于同一导管内。
                检查数量:按每个检验批的配线总回路数抽查20 %，且不得少于1个回路
                """

                if self.project_information['配电总回路数（选填）']:

                    if self.project_information['配电总回路数（选填）'] * 0.2 > 1:
                        number = int(
                            self.project_information['配电总回路数（选填）'] * 0.2)

                else:
                    number = random.randint(3, 10)

                DIR_SHEET.cell(row=key,
                               column=8).value = f'经检查{number}处,合格{number}处,不同回路、不同电压等级和交流与直流线路的绝缘导线未穿于同一导管内'

                DIR_SHEET.cell(row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            if key == 14:
                """
                绝缘导线接头应设置在专用接线盒(箱)或器具内,不得设置在导管和槽盒内盒(箱)的设置位置应便于检修 。
                检查数量:按 每 个 检 验 批 的 配 线 回 路 总 数 抽 查 1 0 % ，且 不 得 少于1个回路。
                """
                if self.project_information.get('配电总回路数（选填）'):

                    if self.project_information['配电总回路数（选填）'] * 0.1 > 1:
                        number = int(
                            self.project_information['配电总回路数（选填）'] * 0.1)

                else:
                    number = random.randint(3, 10)

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number}处,合格{number}处,符合设计及规范要求'
                    DIR_SHEET.cell(row=key, column=8).font = self.FontStyle2
                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'
                    DIR_SHEET.cell(row=key, column=19).font = self.FontStyle2

            if key == 15:

                """
                除塑料护套线外, 绝缘导线应采取导管或槽盒保护，不可外露明敷
                """
                if self.project_information.get('配电总回路数（选填）'):

                    if self.project_information['配电总回路数（选填）'] * 0.1 > 1:
                        number = int(
                            self.project_information['配电总回路数（选填）'] * 0.1)

                else:
                    number = random.randint(3, 10)

                DIR_SHEET.cell(
                    row=key, column=8).value = f'经检查{number}处,合格{number},符合设计及规范要求'
                DIR_SHEET.cell(row=key, column=8).font = self.FontStyle2
                DIR_SHEET.cell(row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'
                DIR_SHEET.cell(row=key, column=19).font = self.FontStyle2
            if key == 16:
                """
                按 每 个 检 验 批 的 绝 缘 导 线 穿 管 数 抽 查 1 0 % ， 且 不 得少 于1 根导管
                """
                if self.project_information.get('绝缘导线穿管数'):

                    if self.project_information['绝缘导线穿管数'] * 0.1 > 1:
                        number = int(self.project_information['绝缘导线穿管数'] * 0.1)

                else:
                    number = random.randint(3, 10)

                DIR_SHEET.cell(
                    row=key, column=8).value = f'经检查{number}处,合格{number},符合设计及规范要求'

                DIR_SHEET.cell(row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            if key == 17:

                """

                与 槽 盒 连 接 的 接 线 盒 ( 箱 ) 应 选 用 明 装 盒 (箱 );
                 配 线 工 程 完 成 后 , 盒 ( 箱 )盖 板 应 齐 全 、完
                """
                if self.project_information['接线盒数量（个）（选填）']:
                    DIR_SHEET.cell(row=key,
                                   column=8).value = f"经检查{self.project_information['接线盒数量（个）（选填）']}处," \
                                                     f"合格{self.project_information['接线盒数量（个）（选填）']}处," \
                                                     f"符合设计及规范要求"
                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            if key == 18:
                """
                当采用多相供电时 ，同一建(构)筑物的绝缘导线绝缘层 颜色应一致。
                检查数量:按每个检验批的绝缘导线配线总回路数抽查10%且不得少于1个回路 。
                """
                if self.project_information.get('配电总回路数（选填）'):

                    if self.project_information['配电总回路数（选填）'] * 0.1 > 1:
                        number = int(
                            self.project_information['配电总回路数（选填）'] * 0.1)

                else:
                    number = random.randint(3, 5)

                    DIR_SHEET.cell(row=key,
                                   column=8).value = f'经检查{number}处,合格{number},使用选用明装盒，配线工程完成后，盒（箱）内齐全、完好'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            if key == 19:
                """
                """
                DIR_SHEET.cell(
                    row=key, column=8).value = '敷线完成后,槽盒盖板应复位,盖板齐全、平整、牢固'
                DIR_SHEET.cell(row=key, column=19).value = '同意施工单位的自检结果，符合要求'


class SwitchButton(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑电气']['开关插座风扇安装']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑电气'
        self.project_information['子分部工程'] = '电气照明安装'
        self.project_information['分项工程'] = '插座、开关、风扇安装'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):
        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=7)

    def From1(self):
        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F6'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['X8'] = self.project_information['项目负责人']

        DIR_SHEET['E8'] = self.project_information['施工单位']

        DIR_SHEET['X7'] = self.project_information['检验批部位']

        DIR_SHEET['E10'] = self.project_information['分包单位']

        DIR_SHEET['M10'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['M8'] = self.project_information['施工员']

        DIR_SHEET['X10'] = self.project_information['建筑电气施工组长']

        for key in range(12, 100):

            # 交流、直流或不同电压等级在同一场所的插座应有区别

            if key == 12:
                DIR_SHEET.cell(
                    row=key, column=8).value = '不同电流和不同电压等级在同一场所的插座有区别'
                number = random.randint(4, 10)
                DIR_SHEET.cell(
                    row=key, column=19).value = f"经检查{number}处,合格{number}处，符合规范要求"

            # 不间断电源插座及应急电源插座的标识设置
            if key == 13:
                DIR_SHEET.cell(
                    row=key, column=8).value = '不间断电源插座及应急电源插座的已按照要求设置标识'
                number = random.randint(4, 10)
                DIR_SHEET.cell(
                    row=key, column=19).value = f"经检查{number}处,合格{number}处，符合规范要求"

            # 插座的接线
            if key == 14:
                number = random.randint(4, 10)
                DIR_SHEET.cell(
                    row=key, column=8).value = f"检查{number}处,合格{number}处，符合规范要求"
                DIR_SHEET.cell(
                    row=key, column=19).value = f"经检查{number}处,合格{number}处，符合规范要求"

            # 照明开关的安装
            if key == 15:

                number = 0

                # 后续还需要读取多少种规格的开关数量
                button_type_number = len(
                    self.project_information['开关类型/规格/数量'].split('、'))

                for n in range(button_type_number):
                    number += 1

                DIR_SHEET.cell(
                    row=key, column=8).value = f"检查{number}处,合格{number}处，符合规范要求"
                DIR_SHEET.cell(
                    row=key, column=19).value = f"经检查{number}处,合格{number}处，符合规范要求"

            # 温控器的接线、显示屏的指示、安装的标高
            if key == 16:

                if self.project_information.get('温控器数量'):

                    if int(self.project_information['温控器数量']) * 0.1 > 1:

                        number = int(
                            int(self.project_information['温控器数量']) * 0.1)

                    else:
                        number = random.randint(3, 10)

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

                # 吊扇的安装
            if key == 17:
                if self.project_information.get('吊扇的数量'):

                    if self.project_information['吊扇的数量'] * 0.05 > 1:

                        number = int(self.project_information['吊扇的数量'] * 0.05)

                    else:
                        number = random.randint(
                            1, self.project_information['吊扇的数量'])

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'
            # 壁扇的安装

            if key == 18:
                if self.project_information.get('壁扇的数量'):

                    if self.project_information['壁扇的数量'] * 0.05 >= 1:
                        min_check_number = int(
                            self.project_information['壁扇的数量'] * 0.05)

                        number = random.randint(
                            min_check_number, min_check_number + 10)

                    else:
                        number = random.randint(
                            1, self.project_information['壁扇的数量'])  # 至少检查1个到插座数量

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'
            # 暗装的插座盒或开关盒的安装和外观检查

            if key == 19:

                if self.project_information.get('暗装插座数量'):

                    if self.project_information['暗装插座数量'] * 0.1 > 1:
                        min_check_number = int(
                            self.project_information['暗装插座数量'] * 0.1)

                        number = random.randint(
                            min_check_number, min_check_number + 10)

                    else:
                        number = random.randint(
                            1, self.project_information['暗装插座数量'])  # 至少检查1个到插座数量

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'
            # 插座的安装
            if key == 20:

                if self.project_information.get('插座数量'):

                    if self.project_information['插座数量'] * 0.1 > 1:
                        min_check_number = int(
                            self.project_information['插座数量'] * 0.1)

                        number = random.randint(
                            min_check_number, min_check_number + 10)
                    else:
                        number = random.randint(
                            1, self.project_information['插座数量'])  # 至少检查1个到插座数量

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            # 照明开关的安装
            if key == 21:

                if self.project_information.get('照明开关数量'):

                    if self.project_information['照明开关数量'] * 0.1 > 1:
                        min_check_number = int(
                            self.project_information['照明开关数量'] * 0.1)

                        number = random.randint(
                            min_check_number, min_check_number + 10)
                    else:
                        number = random.randint(
                            1, self.project_information['照明开关数量'])  # 至少检查1个到插座数量

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            # 温控器的安装高度、控制顺序
            if key == 22:
                if self.project_information.get('温控器数量'):

                    if self.project_information['温控器数量'] * 0.1 > 1:
                        min_check_number = int(
                            self.project_information['温控器数量'] * 0.1)

                        number = random.randint(
                            min_check_number, min_check_number + 10)
                    else:
                        number = random.randint(
                            1, self.project_information['温控器数量'])  # 至少检查1个到插座数量

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            #  吊扇的安装
            if key == 23:

                if self.project_information.get('吊扇的数量'):

                    if self.project_information['吊扇的数量'] * 0.1 > 1:

                        number = int(self.project_information['吊扇的数量'] * 0.1)

                    else:
                        number = 1

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            #  壁扇的安装
            if key == 24:
                if self.project_information.get('壁扇的数量'):

                    if self.project_information['壁扇的数量'] * 0.1 > 1:

                        number = int(self.project_information['壁扇的数量'] * 0.1)

                    else:
                        number = 1

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'

            #  换气扇的安装、定时开关设置
            if key == 25:

                if self.project_information.get('换气扇的数量'):

                    if self.project_information['换气扇的数量'] * 0.1 > 1:

                        number = int(self.project_information['换气扇的数量'] * 0.1)

                    else:
                        number = 1

                    DIR_SHEET.cell(
                        row=key, column=8).value = f'经检查{number},合格{number},符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=19).value = f'同意施工单位自检结果，符合规范要求'


class ElectricityWire(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑电气']['电线导管穿线和敷设']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑电气'
        self.project_information['子分部工程'] = '电气照明安装'
        self.project_information['分项工程'] = '电线、电缆穿管和线槽敷线'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}(导管敷设){self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):

        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=8)
        self.FontStyle2 = Font(size=9)

    def From1(self):

        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F6'] = f"{self.project_information['项目名称']}" + \
                          "({self.project_information['单位工程']})"

        DIR_SHEET['X8'] = self.project_information['项目负责人']

        DIR_SHEET['E8'] = self.project_information['施工单位']

        DIR_SHEET['X7'] = self.project_information['检验批部位']

        DIR_SHEET['E10'] = self.project_information['分包单位']

        DIR_SHEET['M10'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['M8'] = self.project_information['施工员']

        DIR_SHEET['X10'] = self.project_information['建筑电气施工组长']

        self.project_information['检查数量'] = random.randint(3, 10)

        for key in range(12, 100):

            if key == 12:

                if self.project_information['导管材质'] == '金属':
                    DIR_SHEET.cell(
                        row=key, column=8).value = '金属导管与保护导体的连接符合符合要求'

                    DIR_SHEET.cell(
                        row=key, column=8).font = self.FontStyle1
                    DIR_SHEET.cell(
                        row=key, column=19).value = '同意施工单位的自检结果，符合要求'

                    DIR_SHEET.cell(
                        row=key, column=19).font = self.FontStyle1

            if key == 13:

                if self.project_information['导管材质'] == '金属':

                    if self.project_information['金属导管的类型'] == '钢':
                        DIR_SHEET.cell(
                            row=key, column=8).value = '按要求钢导管未采用对口熔焊连接'

                        DIR_SHEET.cell(
                            row=key, column=19).value = '同意施工单位的自检结果，符合要求'

                    if self.project_information['金属导管的类型'] == '镀锌钢导管':
                        DIR_SHEET.cell(
                            row=key, column=8).value = '按要求未采用套管熔焊连接'

                        DIR_SHEET.cell(
                            row=key, column=19).value = '同意施工单位的自检结果，符合要求'

            if key == 14:
                if JudgeBool(self.project_information['导管是否在砌体上埋设']):
                    DIR_SHEET.cell(
                        row=key,
                        column=8).value = f"采用{self.project_information['如果是请填写，水泥砂浆强度']}强度等级的水泥砂浆抹面保护"

                    DIR_SHEET.cell(
                        row=key, column=19).value = "同意施工单位检查结果，符合要求"

            if key == 15:
                DIR_SHEET.cell(row=key, column=8).value = '已按照要求设置预埋套管'

                DIR_SHEET.cell(row=key, column=19).value = '检查结果符合要求'

            if key == 16:
                DIR_SHEET.cell(
                    row=key, column=8).value = f"检查{self.project_information['检查数量']}处," \
                                               f"合格{self.project_information['检查数量']},符合要求"

                DIR_SHEET.cell(row=key, column=19).value = '检查结果符合要求'

            if key == 17:

                if self.project_information['安装方式'] == '明配':
                    DIR_SHEET.cell(
                        row=key, column=8).value = f"检查{self.project_information['检查数量']}处," \
                                                   f"合格{self.project_information['检查数量']},符合要求"

                    DIR_SHEET.cell(row=key, column=19).value = '检查结果符合要求'
            if key == 18:

                if self.project_information['安装方式'] == '暗配':
                    DIR_SHEET.cell(
                        row=key, column=8).value = f"检查{self.project_information['检查数量']}处," \
                                                   f"合格{self.project_information['检查数量']},符合要求"

                    DIR_SHEET.cell(row=key, column=19).value = '经检查,符合设计及规范要求'

            if key == 19:
                number = random.randint(3, 10)

                DIR_SHEET.cell(
                    row=key, column=8).value = f"检查{number}处,合格{number},符合要求"

                DIR_SHEET.cell(row=key, column=19).value = '经检查,符合设计及规范要求'

            if key == 20:
                DIR_SHEET.cell(row=key, column=8).value = '室外导管的敷设符合设计及规范要求'

                DIR_SHEET.cell(row=key, column=19).value = '经检查,符合设计及规范要求'

            if key == 21:

                if self.project_information['安装方式'] == '明配':
                    DIR_SHEET.cell(
                        row=key, column=8).value = '导管排列整齐、固定点间距均匀、安装牢固'

                    DIR_SHEET.cell(row=key, column=19).value = '经检查,符合设计及规范要求'

            if key == 22:

                if self.project_information['导管材质'] == '塑料':
                    DIR_SHEET.cell(
                        row=key, column=8).value = '导管排列整齐、固定点间距均匀、安装牢固'

                    DIR_SHEET.cell(row=key, column=19).value = '经检查,符合设计及规范要求'

            if key == 23:

                if self.project_information['导管材质'] == '金属':

                    if self.project_information['是否可弯曲(是否柔性金属导管)']:
                        DIR_SHEET.cell(
                            row=key, column=8).value = '可弯曲金属导管及柔性导管的敷设符合要求'

                        DIR_SHEET.cell(
                            row=key, column=19).value = '经检查,符合设计及规范要求'

            if key == 24:
                DIR_SHEET.cell(row=key, column=8).value = '导管的敷设符合要求'

                DIR_SHEET.cell(row=key, column=19).value = '经检查,符合设计及规范要求'

            if key == 25:
                DIR_SHEET.cell(row=key, column=8).value = '完整'

                DIR_SHEET.cell(row=key, column=19).value = '符合要求'

            if key == 26:
                DIR_SHEET.cell(row=key, column=8).value = '完整'

                DIR_SHEET.cell(row=key, column=19).value = '符合要求'


# 砖地面（缸砖、水泥花砖、陶瓷锦砖、陶瓷地砖）


class CeramicFloor(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑装饰装修']['砖面层']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑装饰装修'
        self.project_information['子分部工程'] = '地面'
        self.project_information['分项工程'] = '砖面层（陶瓷锦砖、缸砖、陶瓷地砖和水泥花砖面层）'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):

        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=8)
        self.FontStyle2 = Font(size=9)

    def From1(self):

        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G5'] = f"{self.project_information['项目名称']}" \
                          f"({self.project_information['单位工程']})"

        DIR_SHEET['P6'] = self.project_information['项目负责人']

        DIR_SHEET['G6'] = self.project_information['施工单位']

        DIR_SHEET['Y7'] = self.project_information['检验批部位']

        font_size1 = font_size(self.project_information['检验批部位'])

        DIR_SHEET['Y7'].font = Font(size=font_size1)

        DIR_SHEET['G7'] = self.project_information['分包单位']

        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['Y6'] = f"{self.project_information['房间数']}间"

        DIR_SHEET['T3'] = f"编号： {self.project_information['检验批编号']}"

        DIR_SHEET['S33'] = str_date(self.project_information['时间'])

        number = random.randint(3, 10)

        for key in range(10, 50):

            if key == 10:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '材料质量符合设计要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 11:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '已按照要求提供放射性限量合格的检测报告'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 12:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '面层与下一层结合牢固、无缝隙符合要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 13:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '面层表面质量平整光滑无划痕杂色符合要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 14:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '邻接处镶边用料符合设计要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 15:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '踢脚线高度、位置符合设计要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 16:

                if JudgeBool(self.project_information['是否包含楼梯、踏步']):

                    DIR_SHEET.cell(
                        row=key, column=14).value = '全'

                    DIR_SHEET.cell(
                        row=key, column=17).value = '踏步尺寸及面层质量符合设计及规范要求'

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=27).value = '/'

            if key == 17:
                if JudgeBool(self.project_information['是否包含楼梯、踏步']):

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 10)
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'

                else:

                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 18:
                if JudgeBool(self.project_information['是否包含楼梯、踏步']):

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 10)
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'
                else:

                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 19:
                if JudgeBool(self.project_information['是否包含楼梯、踏步']):

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 5)
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

                else:
                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 20:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '面层表面坡度'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 21:
                if self.project_information['地砖类型'] == '缸砖':

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 4)
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 22:
                if self.project_information['地砖类型'] == '水泥花砖':

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 3)
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 23:
                if self.project_information['地砖类型'] in ['陶瓷锦砖', '陶瓷地砖']:

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 2)
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 24:

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 3)
                    DIR_SHEET.cell(
                        row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(
                        row=key, column=17 + n).font = Font(size=8)

                for n2 in range(number, 10):
                    DIR_SHEET.cell(
                        row=key, column=17 + n2).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(
                        row=key, column=17 + n2).font = Font(size=8)

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 25:
                if self.project_information['地砖类型'] in [
                        '陶瓷锦砖', '陶瓷地砖', '水泥花砖']:

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 5) / 10
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 26:
                if self.project_information['地砖类型'] == '缸砖':

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 15) / 10
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'
                else:
                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 27:
                if self.project_information['地砖类型'] in ['陶瓷锦砖', '陶瓷地砖']:

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 30) / 10
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'
                else:
                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 28:
                if self.project_information['地砖类型'] == '缸砖':

                    DIR_SHEET.cell(
                        row=key, column=14).value = number

                    DIR_SHEET.cell(
                        row=key, column=16).value = number

                    for n in range(0, number):
                        DIR_SHEET.cell(
                            row=key, column=17 + n).value = random.randint(0, 4)
                        DIR_SHEET.cell(
                            row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n).font = Font(size=8)

                    for n2 in range(number, 10):
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).value = '/'
                        DIR_SHEET.cell(
                            row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                        DIR_SHEET.cell(
                            row=key, column=17 + n2).font = Font(size=8)

                    DIR_SHEET.cell(
                        row=key, column=27).value = '合格'

                else:
                    DIR_SHEET.cell(row=key, column=14).value = ''

                    DIR_SHEET.merge_cells(
                        start_row=key, start_column=17, end_row=key, end_column=26)

                    DIR_SHEET.cell(row=key, column=17).value = '/'

                    DIR_SHEET.cell(
                        row=key, column=17).alignment = Alignment(
                        horizontal='center', vertical='center')

                    DIR_SHEET.cell(row=key, column=27).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=27).alignment = Alignment(
                        horizontal='center', vertical='center')

            if key == 29:

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 2)
                    DIR_SHEET.cell(
                        row=key, column=17 + n).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(
                        row=key, column=17 + n).font = Font(size=8)

                for n2 in range(number, 10):
                    DIR_SHEET.cell(
                        row=key, column=17 + n2).value = '/'
                    DIR_SHEET.cell(
                        row=key, column=17 + n2).alignment = Alignment(horizontal='center', vertical='center')

                    DIR_SHEET.cell(
                        row=key, column=17 + n2).font = Font(size=8)

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            # 大理石花岗岩面层


class MarbleFloor(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑装饰装修']['大理石面层']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑装饰装修'
        self.project_information['子分部工程'] = '地面'
        self.project_information['分项工程'] = '大理石面层和花岗岩面层'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):

        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=8)
        self.FontStyle2 = Font(size=9)

    def From1(self):

        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G5'] = f"{self.project_information['项目名称']}" + \
                          "({self.project_information['单位工程']})"

        DIR_SHEET['P6'] = self.project_information['项目负责人']

        DIR_SHEET['G6'] = self.project_information['施工单位']

        DIR_SHEET['Z7'] = self.project_information['检验批部位']

        DIR_SHEET['G7'] = self.project_information['分包单位']

        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['T3'] = self.project_information['检验批编号']

        number = random.randint(3, 10)

        for key in range(10, 50):

            if key == 10:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '材料质量符合设计要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 11:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '已按照要求提供放射性限量合格的检测报告'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 12:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '面层与下一层结合符合要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 13:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '板块背面侧面防碱处理符合规范要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 14:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '面层质量符合设计要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 15:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '踢脚线质量符合设计要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 16 and JudgeBool(self.project_information['是否包含楼梯、踏步']):
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '踏步尺寸及面层质量符合规范要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 17 and JudgeBool(self.project_information['是否包含楼梯、踏步']):

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 10)

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 18 and JudgeBool(self.project_information['是否包含楼梯、踏步']):

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 10)

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 19 and JudgeBool(self.project_information['是否包含楼梯、踏步']):

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 5)

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 20:
                DIR_SHEET.cell(
                    row=key, column=14).value = '全'

                DIR_SHEET.cell(
                    row=key, column=17).value = '面层表面坡度符合设计要求'

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 21 and self.project_information['地砖类型'] in [
                    '大理石面层', '花岗石面层']:

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 10) / 10

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 22 and self.project_information['地砖类型'] in [
                    '碎拼大理石', '碎拼花岗石面层']:

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 30) / 10

            if key == 23:

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 2) / 10

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 24:

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 5) / 10

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 25:

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 10) / 10

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            if key == 26:

                DIR_SHEET.cell(
                    row=key, column=14).value = number

                DIR_SHEET.cell(
                    row=key, column=16).value = number

                for n in range(0, number):
                    DIR_SHEET.cell(
                        row=key, column=17 + n).value = random.randint(0, 10) / 10

                DIR_SHEET.cell(
                    row=key, column=27).value = '合格'

            # 普通灯具


class CommentLamps(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑装饰装修']['大理石面层']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑装饰装修'
        self.project_information['子分部工程'] = '地面'
        self.project_information['分项工程'] = '大理石面层和花岗岩面层'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def FontStyles(self):
        self.FontStyle = Font(size=7)
        self.FontStyle1 = Font(size=8)
        self.FontStyle2 = Font(size=9)

    def From1(self):
        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['G5'] = f"{self.project_information['项目名称']}" + \
                          "({self.project_information['单位工程']})"

        DIR_SHEET['P6'] = self.project_information['项目负责人']

        DIR_SHEET['G6'] = self.project_information['施工单位']

        DIR_SHEET['Z7'] = self.project_information['检验批部位']

        DIR_SHEET['G7'] = self.project_information['分包单位']

        DIR_SHEET['P7'] = self.project_information['分包单位项目负责人']

        number = random.randint(3, 10)


# 路基


class MunicipalRoadBed:
    global args

    def __init__(self, project_information, inport_sheetname=None,
                 dir_path=TEMPLATES['道路']['路基']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        self.rowdata = {}
        self.projcetdata = {}

        # 读入基础的参数
        self.project_information = project_information
        # self.project_information['分部工程'] = '建筑装饰装修'
        # self.project_information['子分部工程'] = '地面'
        # self.project_information['分项工程'] = '大理石面层和花岗岩面层'
        #
        # self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path
        #
        # print(
        #     f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        #
        # # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # # 生成路径
        # from urls import ThirdBasePath
        #
        # self.paths = ThirdBasePath(
        #     inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # # 获取检验批编号
        # self.project_information['检验批编号'] = self.paths.finally_code()
        # # 生成报审表路径
        # cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        # cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # # 生成报审表分分部分项信息写入报审表
        #
        # cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()
        # 经验批过程中产生的数据后续要用作隐蔽验收里面的内容
        # 生成保存文件的路径

        # __new_path__ = self.paths.THIRD_BASE_PATH
        __new_path__ = '12.xlsx'

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        # CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'
        #
        # CommonCheck_filepaths = os.path.join(
        #     self.paths.SECOND_BASE_PATH, CommonCheck_name)
        #
        # self.project_information['隐蔽验收类型'] = self.inport_sheetname
        #
        # CommonCheck(self.project_information, CommonCheck_filepaths)

    def __write__tab__word(self, DIR_SHEET, row, col, Check_number: int, numrange: list, col_size=10, max_row=1,
                           per=None, accuracy=80):  # 换行写入
        """
        @param row: 起始单位格的行号
        @param col: 起始单位格的列号
        @param Check_number: 需要写入的数量
        @param col_size: 每行限制的数量
        @param max_row:可以写入的最大行数
        @param per:百分比
        @param numrange:取值的范围
        @param accuracy:正确率(默认是80）
        @return:写入数据
        """

        rowdata = {}

        def __error__number(number: int, OldRange: list[int]):  # 生成随机错误数据
            """

            @param number: 数据的总个数
            @param OldRange: 原先范围
            @return: 返回包含错误数据的队列
            """
            numbers = [x for x in range(int(number))]
            bili = random.randint(accuracy, 100) / 100
            true_numer = int(random.randint(int(number * bili), number))

            rowdata['正确的个数'] = true_numer

            error_nume = int(number - true_numer)
            rowdata['错误的个数'] = error_nume

            # print('错误数据的个数：', error_nume)
            random.shuffle(numbers)

            def error_number(size):

                new_size = {}
                args = random.randint(65, 100) / 100
                if size[0] < 0:

                    new_size[0] = int(size[0] / args)
                else:
                    new_size[0] = int(size[0] * args)

                if size[1] < 0:

                    new_size[1] = int(size[1] * args)
                else:
                    new_size[1] = int(size[1] * (1 + args))

                size = {
                    '下限生成': [new_size[0], size[0]],
                    '上限生成': [size[1], new_size[1]]
                }

                if OldRange[0] == 0 or OldRange[1] == 0:
                    if OldRange[0] == 0:
                        return random.randint(*size['上限生成'])

                    if OldRange[1] == 1:
                        return random.randint(*size['下限生成'])

                if random.random() > 0.5:

                    return random.randint(*size['下限生成'])
                else:
                    return random.randint(*size['上限生成'])

            # print('错误个数:',error_nume)
            # print('正确个数:',true_numer)
            list1 = [error_number(OldRange) for _ in range(error_nume)]
            list2 = [random.randint(*OldRange) for _ in range(true_numer)]
            list3 = list(list1 + list2)
            import pandas as pd
            df = pd.DataFrame({'位置': numbers, '数据': list3})
            print('原先表格', df)
            if error_nume == 0:
                rowdata['错误数据所在的位置'] = 0
            else:
                a = df[:error_nume]['位置'].to_list()  # 错误数据所在的位置

                def row_col(num):
                    return [num // col_size, num % col_size]

                rowdata['错误数据所在的位置'] = list(map(lambda x: row_col(x), a))

            return df.sort_values(by=['位置'])['数据'].to_list()
            # return finally_values

        # 检查取值范围的位数
        newrange = numrange
        multiple = 1

        if Check_number > max_row * col_size:
            Check_number = max_row * col_size
        rowdata['检查个数'] = Check_number
        print('检查个数', Check_number)

        if isinstance(numrange[0], float):
            float_len1 = len(str(numrange[0]).split('.')[1])
            if isinstance(numrange[1], float):
                float_len2 = len(str(numrange[1]).split('.')[1])
            else:
                float_len2 = 0
            float_len = max(float_len1, float_len2)
            multiple = 10 ** float_len
            # 调整取值范围整合新的构造函数
            newrange = list(map(lambda x: x * multiple, numrange))

        Check_number = int(Check_number)

        ValueQueue = __error__number(number=Check_number, OldRange=newrange)

        rowdata['数据集'] = copy.copy(ValueQueue)

        self.projcetdata[row] = rowdata

        number1 = Check_number // col_size  # 取整数 看需要几行 18/10=1 等于三行

        if number1 != 0:

            for row_add in range(number1):  #
                for col_add in range(col_size):
                    value = ValueQueue.pop(0) / multiple

                    if per:
                        value = '%.2f' % float(value * 100) + '%'  # 百分比
                    DIR_SHEET.cell(row=row + row_add, column=col + col_add, value=value).alignment = Alignment(
                        horizontal='center', vertical='center', wrap_text=True)
                    DIR_SHEET.cell(
                        row=row +
                        row_add,
                        column=col +
                        col_add).font = Font(
                        size=6)

        number2 = Check_number % col_size  # 取余数

        if number2 != 0:
            # 写入数据
            for col_add in range(number2):
                value = ValueQueue.pop(0) / multiple
                if per:
                    value = '%.2f' % float(value * 100) + '%'
                DIR_SHEET.cell(row=row + number1, column=col + col_add, value=value).alignment = Alignment(
                    horizontal='center', vertical='center', wrap_text=True)
                DIR_SHEET.cell(
                    row=row +
                    number1,
                    column=col +
                    col_add).font = Font(
                    size=6)

            for col_add2 in range(number2, col_size):
                DIR_SHEET.cell(row=row + number1, column=col + col_add2,
                               value="/").alignment = Alignment(
                    horizontal='center', vertical='center', wrap_text=True)
                DIR_SHEET.cell(
                    row=row +
                    number1,
                    column=col +
                    col_add2).font = Font(
                    size=9)

            row_rain = number1 + 1  # 剩下来的行必须要解决

            for row_add in range(row_rain, max_row):
                for col_add in range(col_size):
                    DIR_SHEET.cell(row=row + row_add, column=col + col_add,
                                   value="/").alignment = Alignment(
                        horizontal='center', vertical='center', wrap_text=True)
                    DIR_SHEET.cell(
                        row=row +
                        row_add,
                        column=col +
                        col_add).font = Font(
                        size=9)

        if rowdata['错误数据所在的位置'] != 0:
            for item in rowdata['错误数据所在的位置']:
                _row, _col = item
                __row = row + _row
                __col = col + _col
                print('错误位置的坐标:', [__row, __col])
                __inquire__image__(sheet=DIR_SHEET, row=__row, col=__col)

    def From1(self):
        # 表头
        global args
        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['H4'] = f"{self.project_information['项目名称']}" + \
                          "({self.project_information['单位工程']})"

        DIR_SHEET['AE5'] = self.project_information['项目负责人']

        DIR_SHEET['H5'] = self.project_information['施工单位']

        DIR_SHEET['V7'] = self.project_information['检验批部位']

        DIR_SHEET['H8'] = self.project_information['交方班组']

        DIR_SHEET['V8'] = self.project_information['接方班组']

        DIR_SHEET['AE8'] = self.project_information['时间']

        for row in range(100):
            # 开关件中间有哪个数据可以写的就会自动打开
            swith = {'button1': False, 'button2': False, 'button3': False}

            if self.project_information['道路长度'] * \
                    self.project_information['道路宽度'] % 1000 != 0:
                # 向上加一
                Check_number1 = (int(
                    self.project_information['道路长度'] * self.project_information['道路宽度'] / 1000) + 1) * 3
            else:
                Check_number1 = int(
                    (self.project_information['道路长度'] * self.project_information['道路宽度'] / 1000)) * 3

            # 第一部分的判断
            if row == 11 and \
                    self.project_information['道路等级'] == '城市快速路、主干路':
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.95
                swith['button1'] = True

            if row == 12 and self.project_information['道路等级'] == '次干路':
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.93
                swith['button1'] = True

            if row == 13 and self.project_information['道路等级'] == '支路及其他小路':
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.9
                swith['button1'] = True
                # 换行写入

            if swith['button1']:
                self.__write__tab__word(DIR_SHEET=DIR_SHEET,
                                        row=11, col=22, Check_number=Check_number1,
                                        numrange=[args, 1], col_size=10, max_row=3, per=True, accuracy=100)
                __write__(DIR_SHEET, 11, 32, self.projcetdata[11]['检查个数'])
                __write__(DIR_SHEET, 11, 33, self.projcetdata[11]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[11]['正确的个数'] / self.projcetdata[11]['检查个数'] * 100)
                __write__(DIR_SHEET, 11, 35, per)

            # 第二部分的判断
            if row == 14 and \
                    self.project_information['道路等级'] == '城市快速路、主干路' and \
                    80 < int(self.project_information['路基厚度']):
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.93
                swith['button2'] = True

            if row == 15 and \
                    self.project_information['道路等级'] == '次干路' and \
                    80 < int(self.project_information['路基厚度']):
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.9
                swith['button2'] = True

            if row == 16 and \
                    self.project_information['道路等级'] == '支路及其他小路' and \
                    80 < int(self.project_information['路基厚度']):
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.9
                swith['button2'] = True

            if swith['button2']:
                self.__write__tab__word(DIR_SHEET, 14, 22, Check_number1,
                                        numrange=[args, 1], col_size=10, max_row=3, per=True, accuracy=100)

                __write__(DIR_SHEET, 14, 32, self.projcetdata[14]['检查个数'])
                __write__(DIR_SHEET, 14, 33, self.projcetdata[14]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[14]['正确的个数'] / self.projcetdata[14]['检查个数'] * 100)
                __write__(DIR_SHEET, 14, 35, per)

            # 第三部分的判断
            if row == 17 and \
                    self.project_information['道路等级'] == '城市快速路、主干路' and \
                    int(self.project_information['路基厚度']) > 150:
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.9
                swith['button3'] = True

            if row == 18 and \
                    self.project_information['道路等级'] == '次干路' and \
                    int(self.project_information['路基厚度']) > 150:
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.9
                swith['button3'] = True

            if row == 19 and \
                    self.project_information['道路等级'] == '支路及其他小路' and \
                    int(self.project_information['路基厚度']) > 150:
                __write__(DIR_SHEET, row, 8, '√')
                args = 0.87
                swith['button3'] = True

            if swith['button3']:
                self.__write__tab__word(DIR_SHEET, 17, 22, Check_number1,
                                        numrange=[args, 1], col_size=10, max_row=3, per=True, accuracy=100)
                __write__(DIR_SHEET, 17, 32, self.projcetdata[17]['检查个数'])
                __write__(DIR_SHEET, 17, 33, self.projcetdata[17]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[17]['正确的个数'] / self.projcetdata[17]['检查个数'] * 100)
                __write__(DIR_SHEET, 17, 35, per)

            #  弯沉值

            if row == 20:
                pass

                # if self.project_information['设计弯沉值']:
                #     __write__(DIR_SHEET,row, 10, self.project_information['设计弯沉值'])
                #     for col_add in range(10):
                #         value=self.project_information['设计弯沉值']+random.random()
                #         __write__(DIR_SHEET,row,22+col_add,value=value)

            if row == 21:
                checknumber = self.project_information['道路长度'] / 20
                self.__write__tab__word(
                    DIR_SHEET, row, 22, checknumber, numrange=[-20, 10], col_size=10, max_row=1)
                __write__(DIR_SHEET, row, 32, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 35, per)

            if row == 22:
                checknumber = self.project_information['道路长度'] / 100 * 2
                self.__write__tab__word(
                    DIR_SHEET, row, 22, checknumber, numrange=[
                        0, 30], col_size=10, max_row=1)
                __write__(DIR_SHEET, row, 32, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 35, per)

            if row == 23:
                checknumber = self.project_information['道路长度'] / \
                    20 * random.randint(1, 3)
                self.__write__tab__word(
                    DIR_SHEET, row, 22, checknumber, numrange=[
                        0, 15], max_row=2)
                __write__(DIR_SHEET, row, 32, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 35, per)

            if row == 25:
                checknumber = self.project_information['道路长度'] / 40
                B = 500
                __write__(DIR_SHEET, row, 12, 500)
                loadwidth = int(self.project_information['路床宽度']) + B
                self.__write__tab__word(
                    DIR_SHEET, row, 22, checknumber, numrange=[
                        loadwidth, loadwidth + 500])
                __write__(DIR_SHEET, row, 32, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 35, per)

            if row == 26:
                checknumber = self.project_information['道路长度'] / \
                    20 * random.randint(2, 6)
                self.__write__tab__word(
                    DIR_SHEET, row, 22, checknumber, numrange=[-0.003, +0.003], max_row=3, per=True)
                __write__(DIR_SHEET, row, 32, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 35, per)

            if row == 29:
                if self.project_information['边坡设计值']:
                    B1 = float(self.project_information['边坡设计值'])
                    B2 = float(B1 - 0.2)
                    checknumber = self.project_information['道路长度'] / 20
                    self.__write__tab__word(
                        DIR_SHEET,
                        row,
                        22,
                        checknumber,
                        numrange=[
                            B2,
                            B1])
                    __write__(DIR_SHEET, row, 32, checknumber)


# 基层


class MunicipalRoadGrass:
    global args

    def __init__(self, project_information, inport_sheetname=None,
                 dir_path=TEMPLATES['道路']['基层']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        self.rowdata = {}
        self.projcetdata = {}

        # 读入基础的参数
        self.project_information = project_information
        # self.project_information['分部工程'] = '建筑装饰装修'
        # self.project_information['子分部工程'] = '地面'
        # self.project_information['分项工程'] = '大理石面层和花岗岩面层'
        #
        # self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path
        #
        # print(
        #     f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        #
        # # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # # 生成路径
        # from urls import ThirdBasePath
        #
        # self.paths = ThirdBasePath(
        #     inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # # 获取检验批编号
        # self.project_information['检验批编号'] = self.paths.finally_code()
        # # 生成报审表路径
        # cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        # cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # # 生成报审表分分部分项信息写入报审表
        #
        # cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()
        # 经验批过程中产生的数据后续要用作隐蔽验收里面的内容
        # 生成保存文件的路径

        # __new_path__ = self.paths.THIRD_BASE_PATH
        __new_path__ = '123.xlsx'

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        # CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'
        #
        # CommonCheck_filepaths = os.path.join(
        #     self.paths.SECOND_BASE_PATH, CommonCheck_name)
        #
        # self.project_information['隐蔽验收类型'] = self.inport_sheetname
        #
        # CommonCheck(self.project_information, CommonCheck_filepaths)

    def __write__tab__word(self, DIR_SHEET, row, col, Check_number: int, numrange: list, col_size=10, max_row=1,
                           per=None, accuracy=80):  # 换行写入
        """
        @param row: 起始单位格的行号
        @param col: 起始单位格的列号
        @param Check_number: 需要写入的数量
        @param col_size: 每行限制的数量
        @param max_row:可以写入的最大行数
        @param per:百分比
        @param numrange:取值的范围
        @param accuracy:正确率(默认是80）
        @return:写入数据
        """

        rowdata = {}

        def __error__number(number: int, OldRange: list):  # 生成随机错误数据
            """

            @param number: 数据的总个数
            @param OldRange: 原先范围
            @return: 返回包含错误数据的队列
            """
            numbers = [x for x in range(int(number))]
            bili = random.randint(accuracy, 100) / 100
            true_numer = int(random.randint(int(number * bili), number))

            rowdata['正确的个数'] = true_numer

            error_nume = int(number - true_numer)
            rowdata['错误的个数'] = error_nume

            # print('错误数据的个数：', error_nume)
            random.shuffle(numbers)

            def error_number(size):

                new_size = {}
                args = random.randint(65, 100) / 100
                if size[0] < 0:

                    new_size[0] = int(size[0] / args)
                else:
                    new_size[0] = int(size[0] * args)

                if size[1] < 0:

                    new_size[1] = int(size[1] * args)
                else:
                    new_size[1] = int(size[1] * (1 + args))

                size = {
                    '下限生成': [new_size[0], size[0]],
                    '上限生成': [size[1], new_size[1]]
                }

                if OldRange[0] == 0 or OldRange[1] == 0:
                    if OldRange[0] == 0:
                        return random.randint(*size['上限生成'])

                    if OldRange[1] == 1:
                        return random.randint(*size['下限生成'])

                if random.random() > 0.5:

                    return random.randint(*size['下限生成'])
                else:
                    return random.randint(*size['上限生成'])

            # print('错误个数:',error_nume)
            # print('正确个数:',true_numer)
            list1 = [error_number(OldRange) for _ in range(error_nume)]
            list2 = [random.randint(*OldRange) for _ in range(true_numer)]
            list3 = list(list1 + list2)
            import pandas as pd
            df = pd.DataFrame({'位置': numbers, '数据': list3})
            print('原先表格', df)
            if error_nume == 0:
                rowdata['错误数据所在的位置'] = 0
            else:
                a = df[:error_nume]['位置'].to_list()  # 错误数据所在的位置

                def row_col(num):
                    return [num // col_size, num % col_size]

                rowdata['错误数据所在的位置'] = list(map(lambda x: row_col(x), a))

            return df.sort_values(by=['位置'])['数据'].to_list()
            # return finally_values

        # 检查取值范围的位数
        newrange = numrange
        multiple = 1

        if Check_number > max_row * col_size:
            Check_number = max_row * col_size
        rowdata['检查个数'] = Check_number
        print('检查个数', Check_number)

        if isinstance(numrange[0], float):
            float_len1 = len(str(numrange[0]).split('.')[1])
            if isinstance(numrange[1], float):
                float_len2 = len(str(numrange[1]).split('.')[1])
            else:
                float_len2 = 0
            float_len = max(float_len1, float_len2)
            multiple = 10 ** float_len
            # 调整取值范围整合新的构造函数
            newrange = list(map(lambda x: x * multiple, numrange))

        Check_number = int(Check_number)

        ValueQueue = __error__number(number=Check_number, OldRange=newrange)

        rowdata['数据集'] = copy.copy(ValueQueue)

        self.projcetdata[row] = rowdata

        number1 = Check_number // col_size  # 取整数 看需要几行 18/10=1 等于三行

        if number1 != 0:

            for row_add in range(number1):  #
                for col_add in range(col_size):
                    value = ValueQueue.pop(0) / multiple

                    if per:
                        value = '%.2f' % float(value * 100) + '%'  # 百分比
                    DIR_SHEET.cell(row=row + row_add, column=col + col_add, value=value).alignment = Alignment(
                        horizontal='center', vertical='center', wrap_text=True)
                    DIR_SHEET.cell(
                        row=row +
                        row_add,
                        column=col +
                        col_add).font = Font(
                        size=6)

        number2 = Check_number % col_size  # 取余数

        if number2 != 0:
            # 写入数据
            for col_add in range(number2):
                value = ValueQueue.pop(0) / multiple
                if per:
                    value = '%.2f' % float(value * 100) + '%'
                DIR_SHEET.cell(row=row + number1, column=col + col_add, value=value).alignment = Alignment(
                    horizontal='center', vertical='center', wrap_text=True)
                DIR_SHEET.cell(
                    row=row +
                    number1,
                    column=col +
                    col_add).font = Font(
                    size=6)

            for col_add2 in range(number2, col_size):
                DIR_SHEET.cell(row=row + number1, column=col + col_add2,
                               value="/").alignment = Alignment(
                    horizontal='center', vertical='center', wrap_text=True)
                DIR_SHEET.cell(
                    row=row +
                    number1,
                    column=col +
                    col_add2).font = Font(
                    size=9)

            row_rain = number1 + 1  # 剩下来的行必须要解决

            for row_add in range(row_rain, max_row):
                for col_add in range(col_size):
                    DIR_SHEET.cell(row=row + row_add, column=col + col_add,
                                   value="/").alignment = Alignment(
                        horizontal='center', vertical='center', wrap_text=True)
                    DIR_SHEET.cell(
                        row=row +
                        row_add,
                        column=col +
                        col_add).font = Font(
                        size=9)

        if rowdata['错误数据所在的位置'] != 0:
            for item in rowdata['错误数据所在的位置']:
                _row, _col = item
                __row = row + _row
                __col = col + _col
                print('错误位置的坐标:', [__row, __col])
                __inquire__image__(sheet=DIR_SHEET, row=__row, col=__col)

    def From1(self):
        # 表头
        global args
        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['H4'] = f"{self.project_information['项目名称']}" + \
                          "({self.project_information['单位工程']})"

        DIR_SHEET['AF5'] = self.project_information['项目负责人']

        DIR_SHEET['H5'] = self.project_information['施工单位']

        DIR_SHEET['H6'] = self.project_information['分包单位']

        # DIR_SHEET['X6'] = self.project_information['分包项目经理']

        DIR_SHEET['W7'] = self.project_information['检验批部位']

        DIR_SHEET['H8'] = self.project_information['交方班组']

        DIR_SHEET['W8'] = self.project_information['接方班组']

        DIR_SHEET['AF8'] = self.project_information['时间']

        if self.project_information['道路长度'] * \
                self.project_information['道路宽度'] % 1000 != 0:
            # 向上加一
            Check_number1 = (int(
                self.project_information['道路长度'] * self.project_information['道路宽度'] / 1000) + 1) * 3
        else:
            Check_number1 = int(
                (self.project_information['道路长度'] * self.project_information['道路宽度'] / 1000)) * 3

        for row in range(100):
            # 开关件中间有哪个数据可以写的就会自动打开

            if row == 11:
                __write__(DIR_SHEET, row, 23,
                          f'{self.project_information["检验批部位"]}采用{self.project_information["基层材料"]},符合设计及规范要求')

            # 第一部分的判断

            if row == 12:
                if self.project_information['基层部位'] == '快速路、主干路基层':
                    __write__(DIR_SHEET, 12, 8, '√')
                    args = 0.97

                if self.project_information['基层部位'] == '快速路、主干路底基层':
                    __write__(DIR_SHEET, 13, 8, '√')
                    args = 0.95

                if self.project_information['基层部位'] == '其他等级路基层':
                    __write__(DIR_SHEET, 14, 8, '√')
                    args = 0.95

                if self.project_information['基层部位'] == '其他等级路底基层':
                    __write__(DIR_SHEET, 15, 8, '√')
                    args = 0.93

                    # 换行写入
                if self.project_information['设计压实度']:
                    dir_args = self.project_information['设计压实度']
                else:
                    dir_args = 0
                print('args:', args)

                args1 = max(args, dir_args)
                self.__write__tab__word(DIR_SHEET=DIR_SHEET,
                                        row=row, col=23, Check_number=Check_number1,
                                        numrange=[args1, 1], col_size=10, max_row=4, per=True, accuracy=100)
                __write__(DIR_SHEET, row, 33, self.projcetdata[12]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[12]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[12]['正确的个数'] / self.projcetdata[12]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)
            #  弯沉值
            if row == 17:
                pass

                # if self.project_information['设计弯沉值']:
                #     __write__(DIR_SHEET,row, 10, self.project_information['设计弯沉值'])
                #     for col_add in range(10):
                #         value=self.project_information['设计弯沉值']+random.random()
                #         __write__(DIR_SHEET,row,22+col_add,value=value)

            if row == 18:
                checknumber = self.project_information['道路长度'] / 100
                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[
                        0, 20], col_size=10, max_row=1)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 19:
                checknumber = self.project_information['道路长度'] / 100 * 2
                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[-15, 15], col_size=10, max_row=1)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 20:
                checknumber = self.project_information['道路长度'] / \
                    20 * random.randint(1, 3)
                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[
                        0, 10], max_row=2)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 22:  # 这里还需要一个道理平整度

                checknumber = self.project_information['道路长度'] / 40
                B = 500
                __write__(DIR_SHEET, row, 13, 500)
                loadwidth = int(self.project_information['路床宽度']) + B
                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[
                        loadwidth, loadwidth + 500])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 23:
                checknumber = self.project_information['道路长度'] / \
                    20 * random.randint(2, 6)
                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[-0.003, 0.003], max_row=3, per=True)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 26:
                self.__write__tab__word(
                    DIR_SHEET, row, 23, Check_number1, numrange=[-10, 10], max_row=1)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)


# 路面


class MunicipalRoadSurface:
    global args

    def __init__(self, project_information, inport_sheetname=None,
                 dir_path=TEMPLATES['道路']['面层']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        self.rowdata = {}
        self.projcetdata = {}

        # 读入基础的参数
        self.project_information = project_information
        # self.project_information['分部工程'] = '建筑装饰装修'
        # self.project_information['子分部工程'] = '地面'
        # self.project_information['分项工程'] = '大理石面层和花岗岩面层'
        #
        # self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path
        #
        # print(
        #     f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")
        #
        # # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # # 生成路径
        # from urls import ThirdBasePath
        #
        # self.paths = ThirdBasePath(
        #     inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # # 获取检验批编号
        # self.project_information['检验批编号'] = self.paths.finally_code()
        # # 生成报审表路径
        # cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        # cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # # 生成报审表分分部分项信息写入报审表
        #
        # cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()
        # 经验批过程中产生的数据后续要用作隐蔽验收里面的内容
        # 生成保存文件的路径

        # __new_path__ = self.paths.THIRD_BASE_PATH
        __new_path__ = '1234.xlsx'

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        # CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'
        #
        # CommonCheck_filepaths = os.path.join(
        #     self.paths.SECOND_BASE_PATH, CommonCheck_name)
        #
        # self.project_information['隐蔽验收类型'] = self.inport_sheetname
        #
        # CommonCheck(self.project_information, CommonCheck_filepaths)

    def __write__tab__word(self, DIR_SHEET, row: int, col: int, Check_number: int, numrange: list, col_size: int = 10,
                           max_row: int = 1,
                           per: bool = None, accuracy: int = 80, rowOff=None, colOff=None):  # 换行写入
        """
        @param row: 起始单位格的行号
        @param col: 起始单位格的列号
        @param Check_number: 需要写入的数量
        @param col_size: 每行限制的数量
        @param max_row:可以写入的最大行数
        @param per:百分比
        @param numrange:取值的范围
        @param accuracy:正确率(默认是80）
        @return:写入数据
        """

        global float_len1
        rowdata = {}

        def __error__number(number: int, OldRange: list):  # 生成随机错误数据
            """

            @param number: 数据的总个数
            @param OldRange: 原先范围
            @return: 返回包含错误数据的队列
            """
            numbers = [x for x in range(int(number))]
            bili = random.randint(accuracy, 100) / 100
            true_numer = int(random.randint(int(number * bili), number))

            rowdata['正确的个数'] = true_numer

            error_nume = int(number - true_numer)
            rowdata['错误的个数'] = error_nume

            # print('错误数据的个数：', error_nume)
            random.shuffle(numbers)

            def error_number(size):

                new_size = {}
                args = random.randint(65, 100) / 100
                if size[0] < 0:

                    new_size[0] = int(size[0] / args)
                else:
                    new_size[0] = int(size[0] * args)

                if size[1] < 0:

                    new_size[1] = int(size[1] * args)
                else:
                    new_size[1] = int(size[1] * (1 + args))

                size = {
                    '下限生成': [new_size[0], size[0]],
                    '上限生成': [size[1], new_size[1]]
                }

                if OldRange[0] == 0 or OldRange[1] == 0:
                    if OldRange[0] == 0:
                        return random.randint(*size['上限生成'])

                    if OldRange[1] == 1:
                        return random.randint(*size['下限生成'])

                if random.random() > 0.5:

                    return random.randint(*size['下限生成'])
                else:
                    return random.randint(*size['上限生成'])

            print('错误个数:', error_nume)
            print('正确个数:', true_numer)
            print(OldRange)
            list1 = [error_number(OldRange) for _ in range(error_nume)]
            list2 = [random.randint(*OldRange) for _ in range(true_numer)]
            list3 = list(list1 + list2)
            import pandas as pd
            df = pd.DataFrame({'位置': numbers, '数据': list3})
            print('原先表格', df)
            if error_nume == 0:
                rowdata['错误数据所在的位置'] = 0
            else:
                a = df[:error_nume]['位置'].to_list()  # 错误数据所在的位置

                def row_col(num):
                    return [num // col_size, num % col_size]

                rowdata['错误数据所在的位置'] = list(map(lambda x: row_col(x), a))

            return df.sort_values(by=['位置'])['数据'].to_list()
            # return finally_values

        # 检查取值范围的位数
        newrange = numrange
        multiple = 1

        if Check_number > max_row * col_size:
            Check_number = max_row * col_size
        rowdata['检查个数'] = Check_number
        print('检查个数', Check_number)

        if isinstance(numrange[0], float):
            float_len1 = len(str(numrange[0]).split('.')[1])
        else:
            float_len1 = 0
        if isinstance(numrange[1], float):
            float_len2 = len(str(numrange[1]).split('.')[1])
        else:
            float_len2 = 0
        float_len = max(float_len1, float_len2)
        multiple = 10 ** float_len
        # 调整取值范围整合新的构造函数
        newrange = list(map(lambda x: x * multiple, numrange))
        print('取值范围', newrange)
        Check_number = int(Check_number)

        ValueQueue = __error__number(number=Check_number, OldRange=newrange)

        rowdata['数据集'] = copy.copy(ValueQueue)

        self.projcetdata[row] = rowdata

        number1 = Check_number // col_size  # 取整数 看需要几行 18/10=1 等于三行

        if number1 != 0:

            for row_add in range(number1):  #
                for col_add in range(col_size):
                    value = ValueQueue.pop(0) / multiple

                    if per:
                        value = '%.2f' % float(value * 100) + '%'  # 百分比
                    DIR_SHEET.cell(row=row + row_add, column=col + col_add, value=value).alignment = Alignment(
                        horizontal='center', vertical='center', wrap_text=True)
                    DIR_SHEET.cell(
                        row=row +
                        row_add,
                        column=col +
                        col_add).font = Font(
                        size=6)

        number2 = Check_number % col_size  # 取余数

        if number2 != 0:
            # 写入数据
            for col_add in range(number2):
                value = ValueQueue.pop(0) / multiple
                if per:
                    value = '%.2f' % float(value * 100) + '%'
                DIR_SHEET.cell(row=row + number1, column=col + col_add, value=value).alignment = Alignment(
                    horizontal='center', vertical='center', wrap_text=True)
                DIR_SHEET.cell(
                    row=row +
                    number1,
                    column=col +
                    col_add).font = Font(
                    size=6)

            for col_add2 in range(number2, col_size):
                DIR_SHEET.cell(row=row + number1, column=col + col_add2,
                               value="/").alignment = Alignment(
                    horizontal='center', vertical='center', wrap_text=True)
                DIR_SHEET.cell(
                    row=row +
                    number1,
                    column=col +
                    col_add2).font = Font(
                    size=9)

            row_rain = number1 + 1  # 剩下来的行必须要解决

            for row_add in range(row_rain, max_row):
                for col_add in range(col_size):
                    DIR_SHEET.cell(row=row + row_add, column=col + col_add,
                                   value="/").alignment = Alignment(
                        horizontal='center', vertical='center', wrap_text=True)
                    DIR_SHEET.cell(
                        row=row +
                        row_add,
                        column=col +
                        col_add).font = Font(
                        size=9)

        if rowdata['错误数据所在的位置'] != 0:
            for item in rowdata['错误数据所在的位置']:
                _row, _col = item
                __row = row + _row
                __col = col + _col
                print('错误位置的坐标:', [__row, __col])
                __inquire__image__(
                    sheet=DIR_SHEET,
                    row=__row,
                    col=__col,
                    rowOff=rowOff,
                    colOff=colOff)

    def From1(self):
        # 表头
        global args
        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['H4'] = f"{self.project_information['项目名称']}" + \
                          "({self.project_information['单位工程']})"

        DIR_SHEET['AF5'] = self.project_information['项目负责人']

        DIR_SHEET['H5'] = self.project_information['施工单位']

        DIR_SHEET['H6'] = self.project_information['分包单位']

        # DIR_SHEET['X6'] = self.project_information['分包项目经理']

        DIR_SHEET['W7'] = self.project_information['检验批部位']

        DIR_SHEET['H8'] = self.project_information['交方班组']

        DIR_SHEET['W8'] = self.project_information['接方班组']

        DIR_SHEET['AF8'] = self.project_information['时间']

        if self.project_information['道路长度'] * \
                self.project_information['道路宽度'] % 1000 != 0:
            # 向上加一
            Check_number1 = (int(
                self.project_information['道路长度'] * self.project_information['道路宽度'] / 1000) + 1) * 3
        else:
            Check_number1 = int(
                (self.project_information['道路长度'] * self.project_information['道路宽度'] / 1000)) * 3

        for row in range(100):
            # 开关件中间有哪个数据可以写的就会自动打开

            if row == 11:
                __write__(DIR_SHEET, row, 23,
                          '材料质量符合要求')

            if row == 12:
                __write__(DIR_SHEET, row, 23,
                          f'{self.project_information["检验批部位"]}采用{self.project_information["混凝土强度"]}混凝土,符合设计及规范要求')

            if row == 13:
                self.__write__tab__word(DIR_SHEET, row, 23, int(Check_number1 / 3),
                                        numrange=[-5, 5], accuracy=100)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 14:
                __write__(DIR_SHEET, row, 23,
                          '符合要求')
                __write__(DIR_SHEET, row, 36, '100%')

            if row == 15:
                checknumber = self.project_information['道路长度'] / 20
                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[-15, 15])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 16:
                checknumber = self.project_information['道路长度'] / 100
                self.__write__tab__word(
                    DIR_SHEET,
                    row,
                    23,
                    checknumber,
                    numrange=[
                        0,
                        20])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 17:

                if self.project_information['道路等级'] == '快速路、主干路':
                    args = 1.2

                if self.project_information['道路等级'] == '次干路':
                    args = 2

                checknumber = self.project_information['道路长度'] / 100
                print('args:', args)

                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[
                        0, args], rowOff=60000)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 19:

                if self.project_information['道路等级'] == '快速路、主干路':
                    args = 3
                if self.project_information['道路等级'] == '次干路':
                    args = 5

                checknumber = self.project_information['道路长度'] / 20

                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[
                        0, args], rowOff=60000)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 21:
                checknumber = self.project_information['道路长度'] / 40

                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[-20, 0])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 22:
                checknumber = self.project_information['道路长度'] / 20
                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[-0.003, 0.003], per=True)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 23:
                checknumber = self.project_information['井座数量']
                self.__write__tab__word(
                    DIR_SHEET,
                    row,
                    23,
                    checknumber,
                    numrange=[
                        0,
                        3])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 24:
                checknumber = self.project_information['道路长度'] / 20
                self.__write__tab__word(
                    DIR_SHEET,
                    row,
                    23,
                    checknumber,
                    numrange=[
                        0,
                        3])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 25:
                checknumber = self.project_information['道路长度'] / 100
                self.__write__tab__word(
                    DIR_SHEET,
                    row,
                    23,
                    checknumber,
                    numrange=[
                        0,
                        10])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 26:
                checknumber = self.project_information['道路长度'] / 40
                self.__write__tab__word(
                    DIR_SHEET,
                    row,
                    23,
                    checknumber,
                    numrange=[
                        0,
                        10])
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)

            if row == 27:
                checknumber = self.project_information['道路长度'] / 20
                self.__write__tab__word(
                    DIR_SHEET, row, 23, checknumber, numrange=[
                        0, 0.02], per=True)
                __write__(DIR_SHEET, row, 33, self.projcetdata[row]['检查个数'])
                __write__(DIR_SHEET, row, 34, self.projcetdata[row]['正确的个数'])
                per = "%.2f%%" % (
                    self.projcetdata[row]['正确的个数'] / self.projcetdata[row]['检查个数'] * 100)
                __write__(DIR_SHEET, row, 36, per)


# 墙体保温


class WallsHeat(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑节能']['墙体保温']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑节能'
        self.project_information['子分部工程'] = '围护结构节能工程'
        self.project_information['分项工程'] = '墙体节能工程'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()
        self.From2()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def From1(self):
        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['E6'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['M7'] = self.project_information['项目负责人']

        DIR_SHEET['E7'] = self.project_information['施工单位']

        DIR_SHEET['R8'] = self.project_information['检验批部位']

        DIR_SHEET['E8'] = self.project_information['分包单位']

        DIR_SHEET['M8'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['R7'] = str(self.project_information['工程量(面积)']) + 'm²'

        DIR_SHEET['O4'] = f"编号:  {self.project_information['检验批编号']}"

        def __write__(row, column, value):
            DIR_SHEET.cell(row=row, column=column).value = value
            DIR_SHEET.cell(row=row, column=column).font = Font(size=10)
            DIR_SHEET.cell(row=row, column=column).alignment = Alignment(
                horizontal='center', vertical='center', wrap_text=True)

        for key in range(12, 100):

            # 交流、直流或不同电压等级在同一场所的插座应有区别

            if key == 11:

                __write__(key, 11, '全')
                if pd.isnull(self.project_information['厂家名称']) or pd.isnull(
                        self.project_information['材料名称']):
                    __write__(key, 14, f'本部位采用{self.project_information["厂家名称"]}'
                                       f'生产的{self.project_information["材料名称"]},符合设计及规范要求')
                    __write__(key, 19, '合格')
                else:
                    __write__(key, 14, f'墙体节能工程使用的材料、构件等进场验收时已按照要求进行检验')
                    __write__(key, 19, '合格')

            if key == 12:
                __write__(key, 11, '全')
                __write__(key, 14, f'墙体节能工程使用的材料、产品进场时已按照要求进行检验')
                __write__(key, 19, '合格')

            if key == 13:

                if JudgeBool(self.project_information['是否有预制构件、定型产品或成套技术']):

                    __write__(key, 11, '全')
                    __write__(key, 14, f'质量证明文件和型式检验报告进场时已按照要求进行检验')
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 14:
                if JudgeBool(self.project_information['是否处于严寒或寒冷地区']):

                    __write__(key, 11, '全')
                    __write__(key, 14, f'冻融试验结果符合设计及规范与要求')

                    __write__(key, 19, '合格')
                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 15:
                __write__(key, 11, '全')
                __write__(key, 14, '基层处理符合设计及规范要求')
                __write__(key, 19, '合格')
            if key == 16:
                __write__(key, 11, '全')
                __write__(key, 14, '各层构造做法符合设计及规范要求')
                __write__(key, 19, '合格')

            if key == 17:
                __write__(key, 11, '全')
                __write__(key, 14, '保温隔热材料的厚度、密度符合设计及规范要求')
                __write__(key, 19, '合格')

            if key == 18:
                if JudgeBool(self.project_information['预制保温板']):

                    __write__(key, 11, '全')
                    __write__(key, 14, '保温隔热材料的厚度、密度符合设计及规范要求')
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 19:
                if JudgeBool(self.project_information['保温浆料']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '保温浆料的同条件试件已按照要求进行见证取样检验')
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 20:
                __write__(key, 11, '全')
                __write__(key, 14, '各类饰面层的基层及面层施工符合设计及规范要求')
                __write__(key, 19, '合格')

            if key == 21:

                if JudgeBool(self.project_information['保温砌块']):

                    __write__(key, 11, '全')
                    __write__(key, 14, '保温砌块砌筑的墙体施工及其配套砂浆的质量符合设计及规范要求')

                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 22:

                if JudgeBool(self.project_information['预制保温板']):

                    __write__(key, 11, '全')

                    __write__(key, 14, '预制保温墙板的墙体施工质量符合设计及规范要求')
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')

                    __write__(key, 19, '/')

            if key == 23:

                if JudgeBool(self.project_information['保温装饰板']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '保温装饰板的厚度符合设计及规范要求')
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 24:

                if JudgeBool(self.project_information['防火隔离带']):

                    __write__(key, 11, '全')
                    __write__(key, 14, '符合外墙保温样板墙施工方案的要求')
                    __write__(key, 19, '合格')
                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

    def From2(self):
        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[1]]

        DIR_SHEET['O3'] = f"编号:{self.project_information['检验批编号']}"

        def __write__(row, column, value, font_size=10):
            DIR_SHEET.cell(row=row, column=column).value = value
            DIR_SHEET.cell(row=row, column=column).font = Font(size=font_size)
            DIR_SHEET.cell(row=row, column=column).alignment = Alignment(
                horizontal='center', vertical='center', wrap_text=True)

        for key in range(50):
            if key == 6:

                if JudgeBool(self.project_information['防火隔离带']):

                    __write__(key, 11, '全')
                    __write__(key, 14, '符合施工方案的要求')
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 7:
                if JudgeBool(self.project_information['防火隔离带']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '保温材料燃烧性能等级要求符合设计及规范要求')

                    __write__(key, 19, '合格')
                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 8:

                if JudgeBool(self.project_information['隔汽层']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '隔汽层的厚度、材料符合设计及规范要求')
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')
            if key == 9:
                __write__(key, 11, '全')
                __write__(
                    key,
                    14,
                    '外墙和毗邻不供暖空间墙体上的门窗洞口、凸窗四周的侧面的节能保温措施',
                    font_size=6)
                __write__(key, 19, '合格')

            if key == 10:
                if JudgeBool(self.project_information['是否处于严寒或寒冷地区']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '是否处于严寒或寒冷地区')
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 11:
                __write__(key, 11, '全')
                __write__(key, 14, '保温材料与构件的外观和包装符合设计及规范要求')
                __write__(key, 19, '合格')

            if key == 12:

                if JudgeBool(self.project_information['增强网']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '增强网的铺贴和搭接符合设计及规范要求')
                    __write__(key, 19, '合格')
                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 13:
                __write__(key, 11, '全')
                __write__(
                    key,
                    14,
                    '设置集中供暖和空调房间外墙热桥部位的节能保温措施符合设计要求',
                    font_size=6)
                __write__(key, 19, '合格')

            if key == 14:
                __write__(key, 11, '全')
                __write__(key, 14, '无影响外墙保温效果的缺陷')
                __write__(key, 19, '合格')

            if key == 15:

                if JudgeBool(self.project_information['保温板']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '墙体保温板材粘贴和接缝处理符合设计及规范要求', font_size=6)
                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 16:
                if self.project_information['施工区域'] == '室外' and JudgeBool(
                        self.project_information['保温板']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '保温层厚度符合设计及规范要求')
                    __write__(key, 19, '合格')
                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')

            if key == 17:
                if JudgeBool(self.project_information['保温浆料']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '保温浆料施工质量符合设计及规范要求', font_size=8)

                    __write__(key, 19, '合格')

                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')
            if key == 18:
                __write__(key, 11, '全')
                __write__(key, 14, '保温层的防止开裂和破损的加强措施符合设计及规范要求')
                __write__(key, 19, '合格')

            if key == 19:

                if JudgeBool(self.project_information['有机保温材料']):
                    __write__(key, 11, '全')
                    __write__(key, 14, '有机保温材料的施工质量符合设计及规范要求')
                    __write__(key, 19, '合格')
                else:
                    __write__(key, 14, '/')
                    __write__(key, 19, '/')


class Earthing(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑电气']['接地装置安装']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑电气'
        self.project_information['子分部工程'] = '防雷及接地安装'
        self.project_information['分项工程'] = '接地装置安装'

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def From1(self):
        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F5'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['X7'] = self.project_information['项目负责人']

        DIR_SHEET['E7'] = self.project_information['施工单位']

        DIR_SHEET['X6'] = self.project_information['检验批部位']

        DIR_SHEET['E9'] = self.project_information['分包单位']

        DIR_SHEET['M9'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['P3'] = f"编号:{self.project_information['检验批编号']}"

        DIR_SHEET['X9'] = self.project_information['建筑电气施工组长']

        DIR_SHEET['T23'] = str_date(self.project_information['时间'])

        def __write__(row, column, value, font_size=10):
            DIR_SHEET.cell(row=row, column=column).value = value
            DIR_SHEET.cell(row=row, column=column).font = Font(size=font_size)
            DIR_SHEET.cell(row=row, column=column).alignment = Alignment(
                horizontal='center', vertical='center', wrap_text=True)

        for key in range(100):

            if key == 11:
                __write__(key, 8, '已按照要求设置测试点，测试点未被外墙饰面遮蔽，且有明显标识')
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 12:
                __write__(key, 8, '接地装置的接地电阻值符合设计及规范要求')
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 13:
                __write__(key, 8, f"接地装置采用{self.project_information['规格/型号']}"
                                  f"{self.project_information['材料名称']}，符合设计及规范要求")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 14:
                __write__(key, 8, f"降低接地电阻采取的措施符合设计及规范要求")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 15:
                __write__(key, 8, f"接地装置埋设深度、间距、水平距离符合设计及规范要求")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 16:
                __write__(key, 8, f"接地装置焊接搭接长度、防腐措施符合设计及规范要求")

                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 17:
                __write__(key, 8, f"接地极接头质量符合设计及规范要求")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 18:
                __write__(key, 8, f"采取降阻措施的接地电阻符合设计及规范要求")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')
            if key == 19:
                __write__(key, 8, f"完整")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 20:
                __write__(key, 8, f"齐全")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')


class Isoelectric(object):

    def __init__(self, project_information, inport_sheetname,
                 dir_path=TEMPLATES['建筑电气']['建筑等电位联结']) -> None:
        self.FontStyle1 = None
        self.FontStyle = None
        self.sheet = None
        # 读入基础的参数
        self.project_information = project_information
        self.project_information['分部工程'] = '建筑电气'
        self.project_information['子分部工程'] = '防雷及接地安装'
        self.project_information['分项工程'] = '建筑物等电位连接'

        #

        self.inport_sheetname = inport_sheetname
        self.dir_path = dir_path

        print(
            f"{self.project_information['检验批部位']}的{self.inport_sheetname}开始制作")

        # 读取模板
        self.DirWorkBook = openpyxl.load_workbook(dir_path, data_only=True)
        # 生成路径
        from urls import ThirdBasePath

        self.paths = ThirdBasePath(
            inport_sheetname=self.inport_sheetname, projectInformation=self.project_information)  # 获取路径
        # 获取检验批编号
        self.project_information['检验批编号'] = self.paths.finally_code()
        # 生成报审表路径
        cover_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}报审表.xlsx'
        cover_path = os.path.join(self.paths.SECOND_BASE_PATH, cover_name)
        # 生成报审表分分部分项信息写入报审表

        cover(self.project_information, cover_path)
        # 写入检验批
        self.From1()

        # 生成保存文件的路径

        __new_path__ = self.paths.THIRD_BASE_PATH

        # 保存文件 """

        self.DirWorkBook.save(__new_path__)

        self.DirWorkBook.close()

        # 写入隐蔽验收记录

        CommonCheck_name = f'{self.project_information["检验批部位"]}{self.inport_sheetname}隐蔽验收记录.xlsx'

        CommonCheck_filepaths = os.path.join(
            self.paths.SECOND_BASE_PATH, CommonCheck_name)

        self.project_information['隐蔽验收类型'] = self.inport_sheetname

        CommonCheck(self.project_information, CommonCheck_filepaths)

    def From1(self):
        # 表头

        DIR_SHEET = self.DirWorkBook[self.DirWorkBook.sheetnames[0]]

        DIR_SHEET['F6'] = f"{self.project_information['项目名称']}({self.project_information['单位工程']})"

        DIR_SHEET['X8'] = self.project_information['项目负责人']

        DIR_SHEET['E8'] = self.project_information['施工单位']

        DIR_SHEET['X7'] = self.project_information['检验批部位']

        DIR_SHEET['E10'] = self.project_information['分包单位']

        DIR_SHEET['M10'] = self.project_information['分包单位项目负责人']

        DIR_SHEET['P4'] = f"编号:{self.project_information['检验批编号']}"

        DIR_SHEET['X10'] = self.project_information['建筑电气施工组长']

        DIR_SHEET['T20'] = str_date(self.project_information['时间'])

        def __write__(row, column, value, font_size=10):
            DIR_SHEET.cell(row=row, column=column).value = value
            DIR_SHEET.cell(row=row, column=column).font = Font(size=font_size)
            DIR_SHEET.cell(row=row, column=column).alignment = Alignment(
                horizontal='center', vertical='center', wrap_text=True)

        for key in range(100):

            if key == 12:
                __write__(key, 8, f"{self.project_information['检验批部位']}等电位联结方式采用"
                                  f"{self.project_information['建筑物等电位联结的形式、方法、部位及联结导体的材料、截面积']}符合设计及规范要求",
                          font_size=8)
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 13:
                __write__(key, 8, '等电位联结的外露可导电部分与外界可导电部分的连接可靠')
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 14:
                __write__(key, 8, "需做等电位联结的卫生间内金属部件或零件的外界可导电部分等电位联结的连接可靠")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 15:
                __write__(key, 8, f"等电位联结导体在地下暗敷时，其导体间的连接未采用螺栓压接")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 16:
                __write__(key, 8, f"完整")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')

            if key == 17:
                __write__(key, 8, f"齐全")
                __write__(key, 19, '同意施工单位自检结果，符合设计及规范要求')


if __name__ == "__main__":
    pass
